Skip to content

fix(client) : Fixed the Loan Accounts Screen not displaying loan details.#2601

Merged
biplab1 merged 8 commits intoopenMF:developmentfrom
techsavvy185:loanAccountsScreenDetails
Feb 13, 2026
Merged

fix(client) : Fixed the Loan Accounts Screen not displaying loan details.#2601
biplab1 merged 8 commits intoopenMF:developmentfrom
techsavvy185:loanAccountsScreenDetails

Conversation

@techsavvy185
Copy link
Contributor

@techsavvy185 techsavvy185 commented Feb 4, 2026

Fixes - Jira-#636

Screen_recording_20260209_182033.webm

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the static analysis check ./gradlew check or ci-prepush.sh to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them.

Summary by CodeRabbit

  • New Features

    • Loan accounts now include original loan amount, current loan balance, and amount paid.
    • Loan type labels now use the correct value field for display.
  • Bug Fixes

    • Loan listing displays correct loan balance and amount paid.
    • When a loan is pending approval, balance and paid amount show localized "Not Available" fallback.

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds nullable loan fields (originalLoan, loanBalance, amountPaid) to the network loan model, renames loan type field to value, updates the client-account mapper and Room loan entity to propagate these fields, and adjusts the client UI to show loan balance/amount paid with resource-based fallbacks.

Changes

Cohort / File(s) Summary
Network Models
core/network/.../GetClientsLoanAccounts.kt, core/network/.../GetClientsLoanAccountsType.kt
Added originalLoan, loanBalance, amountPaid to GetClientsLoanAccounts; renamed GetClientsLoanAccountsType.descriptionvalue.
Mapper Logic
core/network/src/commonMain/kotlin/com/mifos/core/network/mappers/clients/GetClientsClientIdAccountMapper.kt
Mapper now reads loanType.value and maps originalLoan, loanBalance, amountPaid into LoanAccountEntity (mapping/propagation updates).
Room Entities
com.mifos.room.entities.accounts.loans.LoanAccountEntity
Entity constructor/signature updated to include originalLoan, loanBalance, amountPaid.
UI Layer
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Display logic updated to use stringResource fallbacks and show loanBalance / amountPaid (handle pendingApproval cases).

Sequence Diagram(s)

sequenceDiagram
    participant API as Network Model
    participant Mapper as ClientIdAccountMapper
    participant DB as Room LoanEntity
    participant UI as ClientLoanAccountsScreen

    API->>Mapper: Return GetClientsLoanAccounts (originalLoan, loanBalance, amountPaid, loanType.value)
    Mapper->>DB: Map to LoanAccountEntity (include originalLoan, loanBalance, amountPaid)
    DB-->>Mapper: Persist/return entity
    Mapper->>UI: Provide domain loan with loanBalance & amountPaid
    UI->>UI: Render loanBalance/amountPaid (use stringResource fallback if pendingApproval)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • biplab1
  • revanthkumarJ
  • therajanmaurya

Poem

🐇 I hopped through fields both new and bright,
originalLoan, loanBalance, amountPaid in sight.
Mapper nudged values down the data trail,
Entities and UI now sing the same tale.
A tiny rabbit clap for the data made right. ✨

🚥 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 summarizes the main change: fixing the Loan Accounts Screen to properly display loan details by adding new fields and updating the UI rendering logic.

✏️ 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

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@core/network/src/commonMain/kotlin/com/mifos/core/network/mappers/clients/GetClientsClientIdAccountMapper.kt`:
- Around line 114-119: The amountPaid calculation in
GetClientsClientIdAccountMapper currently treats a null loanBalance as 0.0
(using it.loanBalance ?: 0.0), which makes amountPaid equal originalLoan when
balance is unknown; change the logic so that when originalLoan is non-null but
loanBalance is null, amountPaid is set to null, otherwise compute amountPaid =
max(0.0, it.originalLoan - it.loanBalance); update the amountPaid branch (the
block referencing it.originalLoan and it.loanBalance) to reflect this safer
null-handling behavior.
🧹 Nitpick comments (1)
core/network/src/commonMain/kotlin/com/mifos/core/network/model/GetClientsLoanAccounts.kt (1)

45-47: New fields added correctly; consider if amountPaid belongs in the network model.

The nullable Double fields with defaults are safe for backward compatibility. However, amountPaid appears to be computed locally in the mapper as max(0.0, originalLoan - loanBalance) rather than received from the API. If the backend doesn't return amountPaid, consider removing it from this network DTO to clarify that it's a derived value, keeping it only in the entity/domain layer.

Also, the KDoc (lines 14-25) should be updated to document these new parameters.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt (1)

174-176: ⚠️ Potential issue | 🟡 Minor

Fallback to 0 for null loan.id may cause incorrect navigation.

If loan.id is null, passing 0 as the ID to ViewAccount or downstream navigation could result in invalid API calls or unexpected behavior.

🛡️ Suggested approach

Consider filtering out loans with null IDs earlier, or handle the null case explicitly (e.g., show an error or skip the action):

 is Actions.ViewAccount -> {
+    loan.id?.let { id ->
+        onAction(ClientLoanAccountsAction.ViewAccount(id))
+    }
-    onAction(
-        ClientLoanAccountsAction.ViewAccount(loan.id ?: 0),
-    )
 }
🤖 Fix all issues with AI agents
In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt`:
- Around line 137-148: The code in ClientLoanAccountsScreen.kt is currently
prepending the currency symbol to the "Not Available" placeholder for
originalLoan, amountPaid, and loanBalance; change the construction so the symbol
(variable symbol) is concatenated only when the underlying value is
non-null/actual (e.g., loan.originalLoan, loan.amountPaid, loan.loanBalance),
and return the plain "Not Available" string if the value is null—update the
expressions that build originalLoan, amountPaid, and loanBalance to
conditionally prepend symbol only for real numeric values.
🧹 Nitpick comments (2)
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt (2)

135-149: Hardcoded "Not Available" strings should use string resources for localization.

The string "Not Available" is repeated multiple times. Extract it to a string resource for consistency and i18n support.

♻️ Suggested approach

Define a string resource (e.g., Res.string.feature_client_not_available) and replace all occurrences:

val notAvailable = stringResource(Res.string.feature_client_not_available)
MifosActionsLoanListingComponent(
    accountNo = loan.accountNo ?: notAvailable,
    loanProduct = loan.productName ?: notAvailable,
    originalLoan = loan.originalLoan?.let { symbol + it.toString() } ?: notAvailable,
    // ... etc
)

181-182: else -> null in when expression is unnecessary.

The onActionClicked lambda doesn't require a return value. Consider using Unit or an empty block for clarity, or remove the else branch entirely if all expected actions are handled.

♻️ Suggested fix
 onActionClicked = { actions ->
     when (actions) {
         is Actions.ViewAccount -> onAction(
             ClientLoanAccountsAction.ViewAccount(loan.id ?: 0),
         )
         is Actions.MakeRepayment -> onAction(
             ClientLoanAccountsAction.MakeRepayment,
         )
-        else -> null
+        else -> Unit
     }
 },

@biplab1
Copy link
Contributor

biplab1 commented Feb 5, 2026

@techsavvy185 Can you tell us the reason why some account are still showing "Not Available"?

Screenshot 2026-02-05 181233

@techsavvy185
Copy link
Contributor Author

@biplab1 Actually that is due to the fact that those accounts are not approved yet. So there actually is no data for them at present.

@techsavvy185
Copy link
Contributor Author

image For example, I have approved 1 more account and it is now showing the relevant details.

@biplab1
Copy link
Contributor

biplab1 commented Feb 5, 2026

@biplab1 Actually that is due to the fact that those accounts are not approved yet. So there actually is no data for them at present.

@techsavvy185 Yes, I thought so. Thanks for confirming.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt (1)

137-139: ⚠️ Potential issue | 🟡 Minor

originalLoan is missing the pendingApproval guard that was added for amountPaid and loanBalance.

If the intent is to show "Not Available" for unapproved loans, originalLoan should follow the same pattern. Currently it will display "$null""$Not Available" regardless of approval status, which is inconsistent with the other two fields.

Proposed fix (combined with the symbol-prepend fix)
-                                    originalLoan = symbol + (
-                                        (loan.originalLoan ?: "Not Available").toString()
-                                        ),
+                                    originalLoan = if (loan.status?.pendingApproval == true) {
+                                        "Not Available"
+                                    } else {
+                                        loan.originalLoan?.let { symbol + it.toString() } ?: "Not Available"
+                                    },
🤖 Fix all issues with AI agents
In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt`:
- Around line 140-163: The current logic prepends symbol to a stringified
fallback "0" for amountPaid and loanBalance even when the values are null (in
ClientLoanAccountsScreen code using amountPaid, loanBalance, symbol and
loan.status?.pendingApproval), which can be misleading; change the fallback so
that when loan.status?.pendingApproval == true you show "Not Available" as now,
and when pendingApproval == false but amountPaid or loanBalance is null use "Not
Available" (or "N/A") instead of "0", and only prepend the currency symbol when
the displayed value is numeric—i.e., check if the chosen display value is
numeric before concatenating symbol so non-numeric "Not Available" is shown
without a currency symbol.

Copy link
Contributor

@biplab1 biplab1 left a comment

Choose a reason for hiding this comment

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

Some minor changes requested.

Copy link
Contributor

@biplab1 biplab1 left a comment

Choose a reason for hiding this comment

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

Looks good to me. This can be merged once the requested updates have been addressed.

@techsavvy185 techsavvy185 force-pushed the loanAccountsScreenDetails branch from 70865c0 to 09b27ae Compare February 10, 2026 15:55
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
core/network/src/commonMain/kotlin/com/mifos/core/network/model/GetClientsLoanAccountsType.kt (1)

14-19: ⚠️ Potential issue | 🟡 Minor

Stale KDoc: @param description should be @param value.

The field was renamed from description to value, but the doc comment still references description.

📝 Proposed fix
 /**
  *
  *
  * `@param` code
- * `@param` description
+ * `@param` value
  * `@param` id
  */
core/network/src/commonMain/kotlin/com/mifos/core/network/mappers/clients/GetClientsClientIdAccountMapper.kt (1)

165-171: ⚠️ Potential issue | 🟡 Minor

Pre-existing: force-unwrap on it.currency!! will crash on null currency.

Not introduced by this PR, but worth noting — if a savings account has a null currency, this will throw a NullPointerException. Consider using safe calls with ?. here as well.

@techsavvy185 techsavvy185 force-pushed the loanAccountsScreenDetails branch from 4e44af6 to e9eb8bc Compare February 11, 2026 13:23
@techsavvy185 techsavvy185 force-pushed the loanAccountsScreenDetails branch from 4bef93c to baaae17 Compare February 12, 2026 16:27
@sonarqubecloud
Copy link

@biplab1 biplab1 merged commit b24fe7a into openMF:development Feb 13, 2026
4 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.

3 participants