Skip to content

WEB-979: Loan view broken for non Working Capital#3645

Open
alberto-art3ch wants to merge 1 commit into
openMF:devfrom
alberto-art3ch:WEB-979/loans-view-broken-for-non-working-capital
Open

WEB-979: Loan view broken for non Working Capital#3645
alberto-art3ch wants to merge 1 commit into
openMF:devfrom
alberto-art3ch:WEB-979/loans-view-broken-for-non-working-capital

Conversation

@alberto-art3ch

@alberto-art3ch alberto-art3ch commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Description

UI loans view appears Broken Incomplete for non Working Capital

Related issues and discussion

WEB-979

Screenshots, if any

image

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

  • Bug Fixes

    • Improved null-safety to prevent errors when loan product or transactions data is missing (avoids runtime access on missing values).
    • Transactions tab now reliably hides when no transactions exist.
    • Strengthened loan ID validation to avoid invalid account lookups.
  • New Features

    • Charge retrieval now supports multiple loan account path types so charge details load correctly for different loan kinds.
    • Working-capital period rates fetching now returns typed results.
  • Refactor

    • Shared loan initialization logic applied to resolvers for more consistent behavior.

@coderabbitai

coderabbitai Bot commented Jun 12, 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

Walkthrough

Resolvers now initialize via LoanBaseResolver; LoansService.getLoansAccountCharge accepts a loanAccountPath for URL construction; working-capital rates are typed; view and component use optional chaining to avoid null/undefined errors.

Changes

Loan Resolver Refactoring and Service Updates

Layer / File(s) Summary
Base resolver truthiness guard
src/app/loans/common-resolvers/loan-base.resolver.ts
LoanBaseResolver.initialize() changes the productType check from a null-specific (!== null) to a truthiness guard, preventing empty-string values from entering product-type mapping logic.
Service method path parameterization
src/app/loans/loans.service.ts
getLoansAccountCharge() signature updated to accept loanAccountPath first and construct the HTTP path using /${loanAccountPath}/${accountId}/charges/${chargeId}; getWorkingCapitalPeriodPaymentRates now returns Observable<PeriodPaymentRateChange[]> and imports the model.
Account-charge resolver inheritance and validation
src/app/loans/common-resolvers/loans-account-charge.resolver.ts
LoansAccountChargeResolver now extends LoanBaseResolver, calls initialize(route), extracts loanId/chargeId from route params, validates loanId is numeric, invokes getLoansAccountCharge(this.loanAccountPath, loanId, chargeId) on valid ids, and returns of([]) when loanId is not numeric.
Working capital period-rates resolver
src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts
LoanPeriodPaymentRatesResolver extends LoanBaseResolver, calls initialize(route), validates numeric loanId and this.isWorkingCapital before calling getWorkingCapitalPeriodPaymentRates(loanId); otherwise returns of([]). Return type narrowed to Observable<PeriodPaymentRateChange[]>.
View component defensive null-safety
src/app/loans/loans-view/loans-view.component.html, src/app/loans/loans-view/loans-view.component.ts
Template and component updated to use optional chaining: transactions?.length and product?.name to avoid runtime errors when those properties are missing.
sequenceDiagram
  participant LoansAccountChargeResolver
  participant LoansService
  participant API
  LoansAccountChargeResolver->>LoansService: getLoansAccountCharge(loanAccountPath, loanId, chargeId)
  LoansService->>API: GET /{loanAccountPath}/{accountId}/charges/{chargeId}
  API-->>LoansService: HTTP response
  LoansService-->>LoansAccountChargeResolver: Observable<...>
Loading

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

  • openMF/web-app#3435: Both PRs involve refactoring loan resolvers to use LoanBaseResolver for initialization and path routing.

Suggested Reviewers

  • adamsaghy
  • IOhacker
🚥 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 'WEB-979: Loan view broken for non Working Capital' accurately reflects the main objective of the pull request, which addresses a bug where the loan view was broken/incomplete for non-working-capital loan types.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@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: 4

🧹 Nitpick comments (1)
src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts (1)

31-32: 💤 Low value

Validate loanId existence before numeric check.

Line 31 extracts loanId which could be null. Line 32's numeric check !isNaN(+loanId) converts null to 0, and !isNaN(0) returns true, allowing the code to proceed with an invalid ID. While the service call would likely fail, it's clearer to validate existence first.

♻️ Proposed refactor for clarity
   resolve(route: ActivatedRouteSnapshot): Observable<any> | null {
     this.initialize(route);
     const loanId = route.paramMap.get('loanId') || route.parent.paramMap.get('loanId');
-    if (!isNaN(+loanId)) {
+    if (loanId && !isNaN(+loanId)) {
       if (this.isWorkingCapital) {
         return this.loansService.getWorkingCapitalPeriodPaymentRates(loanId);
       }
     }
     return null;
   }
🤖 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/common-resolvers/loan-period-payment-rates.resolver.ts`
around lines 31 - 32, The code currently casts route.paramMap.get('loanId')
(which can be null) to a number directly; change the check in the resolver
(loan-period-payment-rates.resolver.ts) to first verify loanId is
non-null/defined and then validate it's numeric before proceeding. Locate the
loanId extraction (const loanId = route.paramMap.get('loanId') ||
route.parent.paramMap.get('loanId')) and replace the guard with an existence
check (e.g., loanId != null or !== null) combined with the numeric check (e.g.,
!isNaN(+loanId)) so you only call the service when loanId is present and
numeric.
🤖 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/common-resolvers/loans-account-charge.resolver.ts`:
- Around line 32-39: The resolver resolve method (resolve in
loans-account-charge.resolver.ts) can return undefined when +loanId is NaN;
change the method signature from Observable<any> to Observable<any> | null and
add an explicit "return null" for the invalid loanId branch (i.e., after the
isNaN(+loanId) check) so the function always returns the declared type; keep the
successful path using
this.loansService.getLoansAccountCharge(this.loanAccountPath, loanId, chargeId).

In `@src/app/loans/loans-view/loans-view.component.html`:
- Line 360: Resolver payload may omit transactions for non-working-capital loans
causing TransactionsTabComponent to fail; update LoanDetailsResolver (the code
that calls loansService.getLoanAccountAssociationDetails(...) and
getWorkingCapitalLoanDetails(...)) to always include transactions: [] in the
returned loanDetailsData, or alternatively add a defensive fallback in
TransactionsTabComponent so that this.loanDetailsData.transactions is set to an
empty array if undefined before any iteration; reference LoanDetailsResolver,
loansService.getLoanAccountAssociationDetails, getWorkingCapitalLoanDetails, and
TransactionsTabComponent when making the change.

In
`@src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts`:
- Line 29: The resolver method resolve(route: ActivatedRouteSnapshot) currently
returns Observable<any>; replace any with a concrete type by defining or
importing a PeriodPaymentRateChange interface that models the API response,
update the resolver signature to return Observable<PeriodPaymentRateChange> |
null, and update the corresponding service method (e.g., the method in
LoansService that fetches period payment rates) to return
Observable<PeriodPaymentRateChange> instead of Observable<any>; ensure all
usages and imports are adjusted to the new type so TypeScript strict mode is
satisfied.
- Around line 29-37: The resolver's resolve method can return null which breaks
the consuming component expecting PeriodPaymentRateChange[]; modify resolve (in
loan-period-payment-rates.resolver.ts) to always return an array by importing
and using RxJS of(...) and return of([]) when no valid loanId or when not
isWorkingCapital, while keeping the existing branch that returns
this.loansService.getWorkingCapitalPeriodPaymentRates(loanId); ensure the import
for of is added to the file.

---

Nitpick comments:
In
`@src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts`:
- Around line 31-32: The code currently casts route.paramMap.get('loanId')
(which can be null) to a number directly; change the check in the resolver
(loan-period-payment-rates.resolver.ts) to first verify loanId is
non-null/defined and then validate it's numeric before proceeding. Locate the
loanId extraction (const loanId = route.paramMap.get('loanId') ||
route.parent.paramMap.get('loanId')) and replace the guard with an existence
check (e.g., loanId != null or !== null) combined with the numeric check (e.g.,
!isNaN(+loanId)) so you only call the service when loanId is present and
numeric.
🪄 Autofix (Beta)

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

Run ID: a0ed0c94-e761-4a9d-a775-49d0f9566ad9

📥 Commits

Reviewing files that changed from the base of the PR and between 070b861 and 196fcf5.

📒 Files selected for processing (6)
  • src/app/loans/common-resolvers/loan-base.resolver.ts
  • src/app/loans/common-resolvers/loans-account-charge.resolver.ts
  • src/app/loans/loans-view/loans-view.component.html
  • src/app/loans/loans-view/loans-view.component.ts
  • src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts
  • src/app/loans/loans.service.ts

Comment thread src/app/loans/common-resolvers/loans-account-charge.resolver.ts
Comment thread src/app/loans/loans-view/loans-view.component.html
@alberto-art3ch alberto-art3ch force-pushed the WEB-979/loans-view-broken-for-non-working-capital branch from 196fcf5 to 279fbdb Compare June 12, 2026 03: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: 2

🤖 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/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts`:
- Around line 26-29: The JSDoc for the resolver method currently declares
"`@returns` {Observable<any>}" but the method actually returns
Observable<PeriodPaymentRateChange[]>; update the JSDoc on the method in
loan-period-payment-rates.resolver.ts to use "`@returns`
{Observable<PeriodPaymentRateChange[]>}" and adjust the short description to
reflect it returns period payment rate change objects (e.g., "Returns period
payment rate change data. `@returns` {Observable<PeriodPaymentRateChange[]>}").
- Around line 31-37: The code is allowing null loanId because +null === 0;
change the validation in the resolver to first ensure the retrieved loanId
string exists (non-null/undefined) and then validate it's numeric before calling
the service: get the id into a local variable (e.g., loanIdStr from
route.paramMap.get(...) || route.parent.paramMap.get(...)), check if (loanIdStr
&& !isNaN(Number(loanIdStr))) and only then call
this.loansService.getWorkingCapitalPeriodPaymentRates(loanIdStr); update
references in initialize(route) / loan-period-payment-rates.resolver functions
accordingly.
🪄 Autofix (Beta)

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

Run ID: 81a87be6-e7a7-48a9-90e1-53a6d62ae32a

📥 Commits

Reviewing files that changed from the base of the PR and between 196fcf5 and 279fbdb.

📒 Files selected for processing (6)
  • src/app/loans/common-resolvers/loan-base.resolver.ts
  • src/app/loans/common-resolvers/loans-account-charge.resolver.ts
  • src/app/loans/loans-view/loans-view.component.html
  • src/app/loans/loans-view/loans-view.component.ts
  • src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts
  • src/app/loans/loans.service.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/app/loans/common-resolvers/loan-base.resolver.ts
  • src/app/loans/loans-view/loans-view.component.html
  • src/app/loans/loans-view/loans-view.component.ts
  • src/app/loans/loans.service.ts
  • src/app/loans/common-resolvers/loans-account-charge.resolver.ts

@alberto-art3ch alberto-art3ch force-pushed the WEB-979/loans-view-broken-for-non-working-capital branch from 279fbdb to e08719a Compare June 12, 2026 03:55

@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.

🧹 Nitpick comments (1)
src/app/loans/loans.service.ts (1)

879-879: 💤 Low value

Consider tightening the loanId parameter type.

The loanId parameter is typed as any, while similar methods in this service use string (e.g., getLoanCharges on line 599, getLoanChargeTemplateResource on line 37). For consistency and type safety, consider changing it to string.

🤖 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` at line 879, The parameter type for
getWorkingCapitalPeriodPaymentRates is currently any; change the loanId
parameter to string to match other methods (e.g., getLoanCharges,
getLoanChargeTemplateResource) for consistency and stronger type safety, update
the function signature getWorkingCapitalPeriodPaymentRates(loanId: string):
Observable<PeriodPaymentRateChange[]> and any internal usages or callers that
pass or expect a different type so they align with the new string type.
🤖 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.

Nitpick comments:
In `@src/app/loans/loans.service.ts`:
- Line 879: The parameter type for getWorkingCapitalPeriodPaymentRates is
currently any; change the loanId parameter to string to match other methods
(e.g., getLoanCharges, getLoanChargeTemplateResource) for consistency and
stronger type safety, update the function signature
getWorkingCapitalPeriodPaymentRates(loanId: string):
Observable<PeriodPaymentRateChange[]> and any internal usages or callers that
pass or expect a different type so they align with the new string type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fcc7d3ea-579c-4385-857a-1c6ca552bae3

📥 Commits

Reviewing files that changed from the base of the PR and between 279fbdb and e08719a.

📒 Files selected for processing (6)
  • src/app/loans/common-resolvers/loan-base.resolver.ts
  • src/app/loans/common-resolvers/loans-account-charge.resolver.ts
  • src/app/loans/loans-view/loans-view.component.html
  • src/app/loans/loans-view/loans-view.component.ts
  • src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts
  • src/app/loans/loans.service.ts
✅ Files skipped from review due to trivial changes (1)
  • src/app/loans/loans-view/loans-view.component.html
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/app/loans/loans-view/loans-view.component.ts
  • src/app/loans/common-resolvers/loans-account-charge.resolver.ts
  • src/app/loans/loans-view/working-capital/common-resolvers/loan-period-payment-rates.resolver.ts

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