WEB-657: Working Capital Loan - Write-Off - #3798
Conversation
|
Note
|
| Layer / File(s) | Summary |
|---|---|
Request contracts and reason loading src/app/loans/models/working-capital/working-capital-loan-account.model.ts, src/app/loans/loans.service.ts |
Added working-capital write-off and undo-write-off request interfaces. Added loading for write-off reason options. |
Write-off form and submission src/app/loans/loans-view/working-capital/loan-account-actions/write-off/*, src/assets/translations/* |
Added the validated write-off form, payload construction, command submission, navigation, styling, and reversal external ID translations. |
Undo write-off form and submission src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/* |
Added the undo-write-off form, optional trimmed fields, validation, submission, error handling, navigation, and styling. |
Loan action integration and details src/app/loans/loans-view/loan-accounts-button-config.ts, src/app/loans/common-resolvers/loan-action-button.resolver.ts, src/app/loans/loans-view/loan-account-actions/*, src/app/loans/loans-view/general-tab/general-tab.component.html |
Added working-capital permissions and status actions. Selected dedicated components and templates. Updated write-off detail rendering. |
Estimated code review effort: 4 (Complex) | ~45 minutes
Sequence Diagram(s)
sequenceDiagram
actor LoanOfficer
participant LoanAccountActionsComponent
participant WorkingCapitalWriteOffComponent
participant LoansService
participant LoanCommandAPI
LoanOfficer->>LoanAccountActionsComponent: select Write Off
LoanAccountActionsComponent->>WorkingCapitalWriteOffComponent: render working-capital form
WorkingCapitalWriteOffComponent->>LoansService: load write-off reason options
WorkingCapitalWriteOffComponent->>LoanCommandAPI: submit writeOff payload
LoanCommandAPI-->>WorkingCapitalWriteOffComponent: return command result
WorkingCapitalWriteOffComponent-->>LoanOfficer: navigate to default loan view
Possibly related PRs
- openMF/web-app#3790: Both PRs add parallel working-capital loan action flows and modify related resolvers, components, models, and translations.
Suggested reviewers: adamsaghy
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly identifies the working-capital loan write-off feature, which is the main change in the pull request. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
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 @coderabbitai help to get the list of available commands.
bd4ff1b to
44b0eb9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.html (1)
14-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the 8px spacing scale.
m-b-20andgap-5pxencode 20px and 5px spacing. Replace them with existing 8px-grid utilities or shared theme variables.As per coding guidelines,
src/**/*.{scss,html}must use the 8px grid and shared styling variables instead of explicit pixel spacing.Also applies to: 35-35
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.html` at line 14, Replace the m-b-20 and gap-5px spacing utilities in the undo-write-off template with existing 8px-grid utilities or shared theme variables, preserving the current layout spacing without explicit non-grid pixel values.Source: Coding guidelines
src/app/loans/loans.service.ts (1)
681-694: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winType the write-off template response.
getWorkingCapitalWriteOffTemplate()returnsObservable<any>and theWriteOffReasonscode/codevalue responses useany[]. MoveWriteOffReasonOption, the code record, the code value shape used here, and{ writeOffReasonOptions }out ofWorkingCapitalWriteOffComponentintosrc/app/loans/models/working-capital/working-capital-loan-account.model.tsso the service can return a typed shareable response.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/loans/loans.service.ts` around lines 681 - 694, Move the write-off-related interfaces currently defined in WorkingCapitalWriteOffComponent into working-capital-loan-account.model.ts, including WriteOffReasonOption, the code record, the code value shape, and the { writeOffReasonOptions } response. Update getWorkingCapitalWriteOffTemplate() to use these shared types instead of any/any[], and update the component imports and references to consume the relocated models.Sources: Coding guidelines, Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/loans/loans-view/general-tab/general-tab.component.html`:
- Around line 114-117: Update the translation key in the write-off reason label
within the general-tab template from “labels.inputs.Write-off Reason” to
“labels.inputs.WriteOff Reason”; leave the surrounding
loanDetails.writeOffReason rendering unchanged.
---
Nitpick comments:
In
`@src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.html`:
- Line 14: Replace the m-b-20 and gap-5px spacing utilities in the
undo-write-off template with existing 8px-grid utilities or shared theme
variables, preserving the current layout spacing without explicit non-grid pixel
values.
In `@src/app/loans/loans.service.ts`:
- Around line 681-694: Move the write-off-related interfaces currently defined
in WorkingCapitalWriteOffComponent into working-capital-loan-account.model.ts,
including WriteOffReasonOption, the code record, the code value shape, and the {
writeOffReasonOptions } response. Update getWorkingCapitalWriteOffTemplate() to
use these shared types instead of any/any[], and update the component imports
and references to consume the relocated models.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 06613eb3-de9e-4266-af81-504a67c6be2e
📒 Files selected for processing (26)
src/app/loans/common-resolvers/loan-action-button.resolver.tssrc/app/loans/loans-view/general-tab/general-tab.component.htmlsrc/app/loans/loans-view/loan-account-actions/loan-account-actions.component.htmlsrc/app/loans/loans-view/loan-account-actions/loan-account-actions.component.tssrc/app/loans/loans-view/loan-accounts-button-config.tssrc/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.htmlsrc/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.scsssrc/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.tssrc/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.htmlsrc/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.scsssrc/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.tssrc/app/loans/loans.service.tssrc/app/loans/models/working-capital/working-capital-loan-account.model.tssrc/assets/translations/cs-CS.jsonsrc/assets/translations/de-DE.jsonsrc/assets/translations/en-US.jsonsrc/assets/translations/es-CL.jsonsrc/assets/translations/es-MX.jsonsrc/assets/translations/fr-FR.jsonsrc/assets/translations/it-IT.jsonsrc/assets/translations/ko-KO.jsonsrc/assets/translations/lt-LT.jsonsrc/assets/translations/lv-LV.jsonsrc/assets/translations/ne-NE.jsonsrc/assets/translations/pt-PT.jsonsrc/assets/translations/sw-SW.json
Description
Adds Write-Off and Undo Write-Off actions for Working Capital loans, mirroring the term-loan flow with dedicated typed components wired into the shared loan action switch. Write-Off posts to
POST /working-capital-loans/{id}/transactions?command=writeOff(reason dropdown sourced from the "WriteOffReasons" code values, since WC has no write-off template) and Undo Write-Off tocommand=undoWriteOff; both gated by theWRITEOFF_WORKINGCAPITALLOAN/UNDOWRITEOFF_WORKINGCAPITALLOANpermissions and the loan status. Includes the terminal-state button config, the written-off date/reason display in the general tab, and theReversal External IdRelated issues and discussion
WEB-657
Screenshots, if any
Screen.Recording.2026-08-04.at.2.26.33.PM.mov
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
If you have multiple commits please combine them into one commit by squashing them.
Read and understood the contribution guidelines at
web-app/.github/CONTRIBUTING.md.Summary by CodeRabbit