Skip to content

feat(loan): Implement navigation from Loan Account Profile to sub-sections - #2631

Merged
therajanmaurya merged 1 commit into
openMF:developmentfrom
kartikey004:feature/loan-account-navigation
Mar 3, 2026
Merged

feat(loan): Implement navigation from Loan Account Profile to sub-sections#2631
therajanmaurya merged 1 commit into
openMF:developmentfrom
kartikey004:feature/loan-account-navigation

Conversation

@kartikey004

@kartikey004 kartikey004 commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Fixes - Jira-#667

Description - This PR implements navigation from the new LoanAccountProfileScreen to Repayment Schedule, Transactions, Charges and Loan Documents sections. The navigation structure now follows the same pattern as the ClientProfile flow.

MIFOSAC-667.mp4

Summary by CodeRabbit

  • Refactor
    • Enhanced navigation flow for loan account profiles with dedicated paths to repayment schedules, transactions, charges, and documents, replacing a generic callback with explicit navigation routes.

@coderabbitai

coderabbitai Bot commented Mar 3, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The pull request refactors loan account profile navigation by replacing a single generic onDetailItemClick callback with four explicit navigation callbacks: navigateToRepaymentSchedule, navigateToTransactions, navigateToCharges, and navigateToDocuments. The dispatch logic is updated to route detail item clicks to appropriate callbacks using a when expression.

Changes

Cohort / File(s) Summary
Loan Account Profile Navigation & Screen
feature/loan/.../loanAccountProfile/LoanAccountProfileNavigation.kt, feature/loan/.../loanAccountProfile/LoanAccountProfileScreen.kt
Replaced single onDetailItemClick callback parameter with four explicit navigation callbacks. Updated LoanAccountProfileScreen to dispatch detail item clicks via a when expression that routes each item type to its corresponding navigation callback, extracting loan ID from state.
Loan Navigation Wiring
feature/loan/.../navigation/LoanNavigation.kt
Wired the four new navigation callbacks in loanDestination, replacing the no-op onDetailItemClick with explicit delegates: three route to navigation controller functions, and documents delegates to onDocumentsClicked with loan ID and ENTITY_TYPE_LOANS.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • itsPronay
  • TheKalpeshPawar

Poem

🐰 Bouncing through callbacks with clarity so bright,
Four paths now replace just one, navigation's right!
Repayments, transactions, charges, and docs align,
Each on their own route, no tangles—just fine!
The loan account hops forward with pure delight! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing navigation from Loan Account Profile to sub-sections (Repayment Schedule, Transactions, Charges, Documents).

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@sonarqubecloud

sonarqubecloud Bot commented Mar 3, 2026

Copy link
Copy Markdown

@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)
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.kt (1)

106-116: Fallback loanId = -1 may silently pass an invalid ID to downstream screens.

If state.loanAccount is null when this event fires, navigation will proceed with loanId = -1, which could cause unexpected behavior or errors in the destination screens. Consider either:

  1. Early-returning when loanAccount is null (similar to line 96), or
  2. Logging a warning when the fallback is used.

Also, the else -> { } branch silently ignores any unhandled LoanAccountProfileActionItem values. If new action items are added in the future, this could hide bugs. Consider making the when exhaustive or adding a log statement.

♻️ Suggested approach
             is LoanAccountEvent.NavigateToDetail -> {
-                val loanId = state.loanAccount?.id ?: -1
+                val loanId = state.loanAccount?.id ?: return@EventsEffect

                 when (event.detailItem) {
                     LoanAccountProfileActionItem.RepaymentSchedule -> navigateToRepaymentSchedule(loanId)
                     LoanAccountProfileActionItem.Transactions -> navigateToTransactions(loanId)
                     LoanAccountProfileActionItem.Charges -> navigateToCharges(loanId)
                     LoanAccountProfileActionItem.Documents -> navigateToDocuments(loanId)
-                    else -> { }
+                    else -> Unit
                 }
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.kt`
around lines 106 - 116, The NavigateToDetail handler uses a fallback loanId = -1
which may send an invalid ID to downstream screens; update the handler in
LoanAccountEvent.NavigateToDetail to early-return if state.loanAccount is null
(like the pattern on line ~96) or at minimum log a warning with context instead
of using -1, and then only call
navigateToRepaymentSchedule/navigateToTransactions/navigateToCharges/navigateToDocuments
with a valid loanId; also remove the silent else -> { } and make the when on
event.detailItem exhaustive or replace the else with a log/error branch so new
LoanAccountProfileActionItem values are not ignored.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.kt`:
- Around line 106-116: The NavigateToDetail handler uses a fallback loanId = -1
which may send an invalid ID to downstream screens; update the handler in
LoanAccountEvent.NavigateToDetail to early-return if state.loanAccount is null
(like the pattern on line ~96) or at minimum log a warning with context instead
of using -1, and then only call
navigateToRepaymentSchedule/navigateToTransactions/navigateToCharges/navigateToDocuments
with a valid loanId; also remove the silent else -> { } and make the when on
event.detailItem exhaustive or replace the else with a log/error branch so new
LoanAccountProfileActionItem values are not ignored.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62141dd and 1676122.

📒 Files selected for processing (3)
  • feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileNavigation.kt
  • feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.kt
  • feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt

@therajanmaurya
therajanmaurya merged commit 1076e7a into openMF:development Mar 3, 2026
5 checks passed
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.

2 participants