feat(loan): Add missing repayment features to the Repayment Form
Summary by CodeRabbit
-
New Features
- Redesigned loan repayment screen with separate content and dialog flows
- Penalty management: selectable penalties and “Select All” option; penalty waiving UI
- Capture additional payment details including account, cheque, routing, receipt, bank and external ID
- Integrated Material date picker for transaction/repayment dates
-
Improvements
- Action-based state handling with clearer loading/error dialogs and navigation on success
- More consistent date formatting and more reliable payment submission status reporting
Walkthrough
This PR refactors loan repayment into an action-driven ViewModel with DataState-backed repository calls and penalty-selection UI, updates date formatting utility, adds payment-detail fields and strings, and bumps the iOS podspec while adding xcconfig/pod_target_xcconfig settings.
Changes
Loan Repayment Feature Modernization — overview
A set of coordinated changes refactors repository contracts and implementations, updates the date helper, rewrites the ViewModel to an action/state machine, rebuilds the Compose screen into dialog/content components with expandable payment-details and penalties sections, and updates navigation/resources.
Loan Repayment Feature Modernization
| Layer / File(s) | Summary |
|---|---|
Repository and Data Model Updates core/data/src/commonMain/kotlin/com/mifos/core/data/repository/LoanRepaymentRepository.kt, core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/LoanRepaymentRepositoryImp.kt, core/database/src/commonMain/kotlin/com/mifos/room/entities/accounts/loans/LoanRepaymentRequestEntity.kt |
submitPayment now returns DataState<LoanRepaymentResponseEntity>; repository implementation accepts NetworkMonitor and DispatcherManager and applies network checks and dispatcher/io context; LoanRepaymentRequestEntity adds optional externalId. |
Date Formatting Utility Refactor core/common/src/commonMain/kotlin/com/mifos/core/common/utils/DateHelper.kt |
Removes FileUtils logger; adds getDateAsString(integersOfDate: List<Int>, pattern: String = "dd MMM yyyy") with validation, placeholder substitution, and zero-padded MM/dd; renames long-list overload to getDateAsStringFromListLong. |
ViewModel Action-Based State Machine feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanRepayment/LoanRepaymentViewModel.kt |
Replaces imperative ViewModel with BaseViewModel<LoanRepaymentState, LoanRepaymentEvent, LoanRepaymentAction>; introduces action handlers, state/event models, loads loan/template/charges (filters penalties), computes penalty/transaction amounts, and submits via repository DataState flows. |
Screen Components and Layout feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanRepayment/LoanRepaymentScreen.kt |
LoanRepaymentScreen now requires NavController, subscribes to stateFlow/eventFlow, and composes LoanRepaymentContent and LoanRepaymentDialog. Adds conditional Material DatePicker, inputs for date/amount/external-id/payment-type, optional ShowPaymentDetails and ShowPenalties animated sections, and a two-button submit/back row. |
UI Resources and Navigation Integration feature/loan/src/commonMain/composeResources/values/strings.xml, feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanRepayment/LoanRepaymentScreenRoute.kt, feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt |
Adds penalty-waiver and payment-detail string resources; updates loanRepaymentScreen route to accept NavController and forwards it; navigation wiring now passes navController explicitly. |
iOS CocoaPods Build Configuration
| Layer / File(s) | Summary |
|---|---|
Podspec Version and XCConfig Setup cmp-shared/cmp_shared.podspec |
Bump spec.version to 2026.5.3; add spec.xcconfig disabling ENABLE_USER_SCRIPT_SANDBOXING; add spec.pod_target_xcconfig setting KOTLIN_PROJECT_PATH to :cmp-shared and PRODUCT_MODULE_NAME to ComposeApp. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
- openMF/mifos-x-field-officer-app#2654: Touches the same
cmp-shared/cmp_shared.podspecxcconfig and pod_target_xcconfig settings. - openMF/mifos-x-field-officer-app#2597: Related prior changes to LoanRepayment UI and confirmation/penalty handling.
- openMF/mifos-x-field-officer-app#2599: Related navigation/ViewModel initialization changes for loan repayment flows.
Suggested reviewers
- itsPronay
- biplab1
- niyajali
[!IMPORTANT]
Pre-merge checks failed
Please resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Jira Link And Before/After Sections | ❌ Error | PR has valid Jira link (MIFOSAC-643) but lacks required "Before:" and "After:" sections with media as specified in check requirements. | Add "Before:" and "After:" sections to PR description, each containing media (image/video) demonstrating the feature before and after changes. |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 4.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 |
|---|---|---|
| Title check | ✅ Passed | The title clearly describes the main change: adding missing repayment features to the Repayment Form. It follows the required commit format with type 'feat' and scope 'loan', uses present tense and lowercase, and is concise without JIRA ticket numbers. |
| Description check | ✅ Passed | The description references the JIRA issue (MIFOSAC-643) that the PR fixes and includes a screen recording demonstrating the changes, which are directly related to the repayment form modifications shown in the changeset. |
✨ 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 and usage tips.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code