Skip to content

WEB-657: Working Capital Loan - Write-Off - #3798

Open
alberto-art3ch wants to merge 1 commit into
openMF:devfrom
alberto-art3ch:WEB-657/working-capital-loan-write-off
Open

WEB-657: Working Capital Loan - Write-Off#3798
alberto-art3ch wants to merge 1 commit into
openMF:devfrom
alberto-art3ch:WEB-657/working-capital-loan-write-off

Conversation

@alberto-art3ch

@alberto-art3ch alberto-art3ch commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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 to command=undoWriteOff; both gated by the WRITEOFF_WORKINGCAPITALLOAN / UNDOWRITEOFF_WORKINGCAPITALLOAN permissions and the loan status. Includes the terminal-state button config, the written-off date/reason display in the general tab, and the Reversal External Id

Related 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

  • New Features
    • Added dedicated write-off and undo write-off workflows for working-capital loans.
    • Added validated fields for dates, reasons, notes, external IDs, and reversal details.
    • Added outstanding balance display and permission-controlled actions.
    • Added a “Closed (written off)” state with an “Undo Write-off” option.
  • Bug Fixes
    • Improved display of write-off dates and reasons across supported formats.
  • Localization
    • Added “Reversal External Id” translations across supported languages.

@alberto-art3ch
alberto-art3ch requested a review from a team August 4, 2026 19:30
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "pre_merge_checks"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: de4aec37-a365-497b-a63a-704fff6923c9

📥 Commits

Reviewing files that changed from the base of the PR and between bd4ff1b and 44b0eb9.

📒 Files selected for processing (26)
  • src/app/loans/common-resolvers/loan-action-button.resolver.ts
  • src/app/loans/loans-view/general-tab/general-tab.component.html
  • src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html
  • src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts
  • src/app/loans/loans-view/loan-accounts-button-config.ts
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.html
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.scss
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.ts
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.html
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.scss
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.ts
  • src/app/loans/loans.service.ts
  • src/app/loans/models/working-capital/working-capital-loan-account.model.ts
  • src/assets/translations/cs-CS.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/en-US.json
  • src/assets/translations/es-CL.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/pt-PT.json
  • src/assets/translations/sw-SW.json
🚧 Files skipped from review as they are similar to previous changes (25)
  • src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html
  • src/assets/translations/cs-CS.json
  • src/assets/translations/es-CL.json
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.scss
  • src/assets/translations/en-US.json
  • src/app/loans/loans.service.ts
  • src/app/loans/loans-view/general-tab/general-tab.component.html
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.html
  • src/assets/translations/it-IT.json
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.html
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.ts
  • src/assets/translations/ne-NE.json
  • src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts
  • src/app/loans/common-resolvers/loan-action-button.resolver.ts
  • src/assets/translations/de-DE.json
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.scss
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.ts
  • src/assets/translations/pt-PT.json
  • src/assets/translations/sw-SW.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/ko-KO.json
  • src/app/loans/loans-view/loan-accounts-button-config.ts

Walkthrough

Working-capital loans now use dedicated write-off and undo-write-off components, request models, permissions, reason loading, loan-action routing, and localized reversal external ID labels.

Changes

Working-capital loan write-off workflow

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
Loading

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@alberto-art3ch
alberto-art3ch force-pushed the WEB-657/working-capital-loan-write-off branch from bd4ff1b to 44b0eb9 Compare August 4, 2026 19:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 win

Use the 8px spacing scale.

m-b-20 and gap-5px encode 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 win

Type the write-off template response.

getWorkingCapitalWriteOffTemplate() returns Observable<any> and the WriteOffReasons code/codevalue responses use any[]. Move WriteOffReasonOption, the code record, the code value shape used here, and { writeOffReasonOptions } out of WorkingCapitalWriteOffComponent into src/app/loans/models/working-capital/working-capital-loan-account.model.ts so 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

📥 Commits

Reviewing files that changed from the base of the PR and between e842bba and bd4ff1b.

📒 Files selected for processing (26)
  • src/app/loans/common-resolvers/loan-action-button.resolver.ts
  • src/app/loans/loans-view/general-tab/general-tab.component.html
  • src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html
  • src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts
  • src/app/loans/loans-view/loan-accounts-button-config.ts
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.html
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.scss
  • src/app/loans/loans-view/working-capital/loan-account-actions/undo-write-off/undo-write-off.component.ts
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.html
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.scss
  • src/app/loans/loans-view/working-capital/loan-account-actions/write-off/write-off.component.ts
  • src/app/loans/loans.service.ts
  • src/app/loans/models/working-capital/working-capital-loan-account.model.ts
  • src/assets/translations/cs-CS.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/en-US.json
  • src/assets/translations/es-CL.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/pt-PT.json
  • src/assets/translations/sw-SW.json

Comment thread src/app/loans/loans-view/general-tab/general-tab.component.html
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.

1 participant