feat(loan): implement loan disburse screen - #2700
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
🧰 Additional context used📓 Path-based instructions (3)**/*Screen.kt⚙️ CodeRabbit configuration file
Files:
**/*.kt⚙️ CodeRabbit configuration file
Files:
**/composeResources/values*/strings.xml⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (3)📚 Learning: 2026-02-06T13:15:16.968ZApplied to files:
📚 Learning: 2026-04-01T05:03:14.323ZApplied to files:
📚 Learning: 2026-07-08T13:55:15.322ZApplied to files:
🔇 Additional comments (3)
Summary by CodeRabbit
WalkthroughThe loan disbursement flow now uses new network, data, domain, and feature-layer contracts. A Compose form loads templates, validates and submits disbursement details, and integrates with typed loan navigation. ChangesLoan disbursement flow View checkpoints
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant LoanAccount
participant LoanNavigation
participant LoanDisburseScreen
participant LoanDisburseViewModel
participant LoanDisburseRepositoryImpl
LoanAccount->>LoanNavigation: select Disburse(loanId)
LoanNavigation->>LoanDisburseScreen: navigate with LoanDisburseRoute
LoanDisburseScreen->>LoanDisburseViewModel: load template
LoanDisburseViewModel->>LoanDisburseRepositoryImpl: getDisburseTemplate(loanId)
LoanDisburseScreen->>LoanDisburseViewModel: submit form
LoanDisburseViewModel->>LoanDisburseRepositoryImpl: disburse(loanId, LoanDisburseInput)
LoanDisburseViewModel-->>LoanDisburseScreen: show result dialog
LoanDisburseScreen-->>LoanNavigation: notify success
Possibly related PRs Related pull requests
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.kt (1)
192-197: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMixed design-token systems:
KptTheme.spacing.mdalongsideDesignToken.spacing.*.Every other spacing/padding call in this file uses
DesignToken; this one lone use ofKptTheme(from the base template package) is inconsistent and risks a visually mismatched scale.🤖 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 `@feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.kt` around lines 192 - 197, Update the Column modifier in LoanDisburseScreen to replace KptTheme.spacing.md with the corresponding DesignToken spacing value, matching the spacing token system used throughout the rest of the file.Source: Path instructions
🤖 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 `@feature/loan/src/commonMain/composeResources/values/strings.xml`:
- Around line 728-744: Remove the duplicate resources feature_loan_disburse,
feature_loan_disburse_transaction_amount, and
feature_loan_disburse_payment_type, and update their call sites to reuse the
existing feature_loan_disburse_loan, feature_loan_transaction_amount, and
feature_loan_payment_type keys. Keep the displayed text unchanged and avoid
introducing parallel keys in the strings resources.
In
`@feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.kt`:
- Around line 240-245: Move the CurrencyFormatter.format calls for balance and
arrears out of the composable in LoanAccountProfileScreen and into the
corresponding ViewModel or mapper. Expose the pre-formatted values through the
screen state model, then have the composable render those state properties
directly while preserving the existing "—" fallback.
In
`@feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.kt`:
- Around line 278-283: Replace the hardcoded "Note" label in the
MifosOutlinedTextField used by LoanDisburseScreen with
stringResource(Res.string.feature_loan_disburse_note), and add the corresponding
feature_loan_disburse_note entry to strings.xml so the field is localized
consistently with the other screen labels.
- Around line 206-224: Update the transaction amount state flow used by
LoanDisburseScreen and its ViewModel so it preserves the raw text, including
empty or otherwise invalid intermediate input, instead of only accepting values
parsed by toDoubleOrNull(). Make LoanDisburseAction.TransactionAmountChanged
carry the raw value, update the displayed text from that state, and validate or
derive the Double separately while setting transactionAmountError for empty or
invalid input.
In
`@feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.kt`:
- Around line 89-101: Update the Success branch of the template-loading flow to
clamp the existing disbursed date against minDate before updating state. Use
that same clamped value for both disbursedDate and disbursedDateText, while
preserving the existing minDisbursementDate assignment and other
LoanDisburseState fields.
---
Nitpick comments:
In
`@feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.kt`:
- Around line 192-197: Update the Column modifier in LoanDisburseScreen to
replace KptTheme.spacing.md with the corresponding DesignToken spacing value,
matching the spacing token system used throughout the rest of the file.
🪄 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: afe26685-029e-4c63-a8b9-a313e707f404
📒 Files selected for processing (34)
core/data/src/commonMain/kotlin/com/mifos/core/data/di/RepositoryModule.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/CurrencyMapper.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/PaymentTypeMapper.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/loan/LoanDisburseMapper.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanAccountDisbursementRepository.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanDisburseRepository.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanAccountDisbursementRepositoryImp.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanDisburseRepositoryImpl.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/di/UseCaseModule.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/GetLoanDisburseTemplateUseCase.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/LoanDisburseUseCase.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/LoanDisbursement.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseInput.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseTemplate.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.ktfeature/loan/src/commonMain/composeResources/values/strings.xmlfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/di/LoanModule.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountAction/LoanAccountActionNavigation.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseNavigation.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseState.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementScreen.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementUiState.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementViewModel.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanDisbursementScreenRoute.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt
💤 Files with no reviewable changes (7)
- feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementUiState.kt
- core/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/LoanDisbursement.kt
- core/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanAccountDisbursementRepository.kt
- core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanAccountDisbursementRepositoryImp.kt
- feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanDisbursementScreenRoute.kt
- feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementViewModel.kt
- feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementScreen.kt
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: PR Checks / Static Analysis Check
🧰 Additional context used
📓 Path-based instructions (11)
**/data/mappers/**/*.kt
⚙️ CodeRabbit configuration file
**/data/mappers/**/*.kt: Mapper Consistency Rules (:core:data:mappers):
- All mapping logic MUST be centralized in this directory.
- Allowed mappings:
- DTO -> Domain Model
- Entity <-> Domain Model
- Flag: Any mapper functions found in any module outside of
:core:data:mappers.
Files:
core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/PaymentTypeMapper.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/CurrencyMapper.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/loan/LoanDisburseMapper.kt
**/{core-base,core}/**/*.kt
⚙️ CodeRabbit configuration file
**/{core-base,core}/**/*.kt: Critical Module Change Detection:
- Changes in
core-basemodule must be treated as high-impact.- Flag any PR that modifies files inside
core-basefor careful review.- Verify that modifications in
core-baseare necessary and minimal.
Output:- Clearly highlight that
core-baseis a shared foundational module and requires extra review attention.
Files:
core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/PaymentTypeMapper.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/di/UseCaseModule.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/GetLoanDisburseTemplateUseCase.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/CurrencyMapper.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseTemplate.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseInput.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/LoanDisburseUseCase.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanDisburseRepository.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/loan/LoanDisburseMapper.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanDisburseRepositoryImpl.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/di/RepositoryModule.kt
**/*.kt
⚙️ CodeRabbit configuration file
**/*.kt: Additional Code Review Guidelines:
- Null Safety & Stability
- Avoid using
!!operator- Handle null cases explicitly using safe calls or proper state handling
- Do not assume values are always non-null without guarantees
- Architecture Boundaries
- ViewModel must not depend on specific network/library implementations
- Ensure proper separation between data, domain, and presentation layers
- Do not format data (currency, dates, calculations) inside the UI layer
- All formatting must be handled in the ViewModel and exposed via state (e.g., StateFlow)
- Performance Considerations
- Avoid unnecessary recompositions in Compose
- Do not attach heavy logic to frequently changing states (e.g., scrollState)
- Prefer lifting state up instead of recomputing in child composables
- Compose & Navigation Best Practices
- NEVER trigger navigation functions or side-effects directly during composition
- Always wrap navigation calls inside
LaunchedEffectorEventsEffectto avoid repeated execution on recomposition- Avoid triggering intensive side-effects during recomposition
- Navigation routes must be type-safe.
- Ensure all route classes or objects used for navigation are annotated with
@Serializable.
- UI Structure
- Dialogs must be separated into their own composables
- Do not embed dialogs inline within complex main screens
- Localization Consistency
- Ensure all supported languages are updated consistently across modules
- Verify translations exist for newly added UI strings
- Code Cleanliness
- Avoid unnecessary inline comments unless critical
- Remove leftover debug or commented code
- Focus on correctness, readability, and maintainability over cosmetic nitpicks.
- Avoid reviewing README, config, or asset files.
- Prioritize identifying bugs, performance issues, and architectural concerns.
- Naming & Intent Rules:
- Follow the official Kotlin Coding Conventions:
https://kotlinlang.org/docs/coding-conventions.html- Use self-explanatory ...
Files:
core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/PaymentTypeMapper.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/di/UseCaseModule.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/GetLoanDisburseTemplateUseCase.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/CurrencyMapper.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseTemplate.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseNavigation.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseInput.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/LoanDisburseUseCase.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanDisburseRepository.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/loan/LoanDisburseMapper.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseState.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/di/LoanModule.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanDisburseRepositoryImpl.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountAction/LoanAccountActionNavigation.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/di/RepositoryModule.kt
**/network/**/*.kt
⚙️ CodeRabbit configuration file
**/network/**/*.kt: Network Layer API Guidelines:
- One-shot API calls MUST use
suspend, return raw responseT, and MUST NOT use Flow or DataState.- Streaming APIs MUST return
Flow<T>and MUST NOT usesuspendor DataState.
Files:
core/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.kt
**/network/dto/**/*.kt
⚙️ CodeRabbit configuration file
**/network/dto/**/*.kt: DTO Rules (:core:network:dto):
- Classes here are Data Transfer Objects (DTOs) used strictly for API communication.
- Rule: DTOs MUST NOT be used in ViewModels, Screens, or the Domain layer.
- Flag: If a DTO is returned directly by a Repository interface or used in UI state.
Files:
core/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.kt
**/composeResources/values*/strings.xml
⚙️ CodeRabbit configuration file
**/composeResources/values*/strings.xml: String resource conventions:Naming:
- All keys must follow:
feature_{feature_name}_{ui_text_in_snake_case}Examples:
"In Advance" → feature_loan_in_advance
"Outstanding" → feature_loan_outstanding
- Avoid generic names like: title, text1, label
- The suffix should be a short, readable representation of the UI text
- Avoid multiple keys representing the same UI text
- Keys must be lowercase and use snake_case
Flag:
- Incorrect naming pattern
- Generic or unclear key names
- Duplicate keys for same UI text
Files:
feature/loan/src/commonMain/composeResources/values/strings.xml
**/core/model/**/*.kt
⚙️ CodeRabbit configuration file
**/core/model/**/*.kt: Domain Model Rules (:core:model):
- Classes defined in this module are strictly Domain Models.
- They must be plain Kotlin data classes.
- They MUST NOT contain network-specific annotations (e.g.,
@Serializable) or database-specific annotations (e.g.,@Entity).- Rule: These are the ONLY models that should be passed to or used within ViewModels and UI Screens.
- Flag: If a Domain model is used directly as an API request/response body or a Room database table.
Files:
core/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseTemplate.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseInput.kt
**/*Screen.kt
⚙️ CodeRabbit configuration file
**/*Screen.kt: Screen architecture rules:Each screen must follow a 2-layer structure:
Layer 1 (Entry/Route Composable):
- Function Name: Typically
*ScreenRouteor the entry-point composable.- Responsibilities: Inject ViewModel (e.g.,
koinViewModel), take navigation lambdas, collect theStateFlow, and handle ViewModel events.- Logic: Should only handle ViewModel interaction, state collection, and triggering navigation in response to ViewModel events.
Layer 2 (Stateful/Content Composable —
*Screenor*ScreenContent):
- Parameters: MUST only take
state(the UI state object) and a singleonActionlambda (e.g.,onAction: (FeatureAction) -> Unit).- Responsibilities: Render the UI based strictly on the provided
state.- Rule: MUST NOT pass multiple separate lambda functions for different UI interactions; consolidate them into the single
onAction.- Constraint: Must NOT contain any business logic or ViewModel/Navigation references.
Internal/private helper composables (e.g., dialogs, sections, sub-components):
- These are NOT subject to the single
onActionrule.- They may accept specific, focused lambdas (e.g.,
onRetry: () -> Unit) or a narrowedonActionas appropriate.- However, they must NOT be passed the ViewModel or navigation controllers directly.
UI consistency:
- Avoid hardcoded values (dp, sp, padding, fontSize, colors)
- Use DesignToken, KptTheme, AppColors, MifosTypography for spacing, typography, and colors
Code quality:
- Keep Composables small and readable
- Avoid deeply nested UI
Flag:
- Missing Layer 2 (
*Screen/*ScreenContent) separation from the entry-point composable- Layer 2 (
*Screen/*ScreenContent) receiving multiple separate lambdas instead of a singleonAction- UI logic inside the entry-point composable
- Business logic inside any Composable
- Hardcoded strings instead of using string resources
- Hardcoded dp/sp values
- Direct styling instead of using DesignToken or KptTheme
Files:
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.kt
**/data/repository/**/*.kt
⚙️ CodeRabbit configuration file
**/data/repository/**/*.kt: Repository Interface Guidelines:
- One-shot operations MUST use
suspend funand returnDataState<T>. MUST NOT use Flow.- Streaming operations MUST return
Flow<DataState<T>>and MUST NOT usesuspend.- Repository interfaces must consistently return Domain models (from :core:model) wrapped in
DataStateorFlow.- Flag: Any interface method that returns a DTO or an Entity.
Files:
core/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanDisburseRepository.kt
**/data/repositoryImp/**/*.kt
⚙️ CodeRabbit configuration file
**/data/repositoryImp/**/*.kt: Repository Implementation Guidelines:
- MUST convert
T->DataState<T>for one-shot APIs, andFlow<T>->Flow<DataState<T>>using.asDataStateFlow().- MUST perform network availability checks, handle exceptions, and apply appropriate dispatchers.
- Repositories act as the boundary translator. They MUST use mappers to convert DTOs (from network) and Entities (from database) into Domain Models (from :core:model) before returning data.
- Flag: If a repository implementation returns a raw DTO or Entity directly to the caller instead of a Domain model.
Files:
core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanDisburseRepositoryImpl.kt
**/*ViewModel.kt
⚙️ CodeRabbit configuration file
**/*ViewModel.kt: MVI architecture rules:
- All new features must follow MVI
- ViewModel must extend BaseViewModel
- The ViewModel MUST maintain a single UI state (e.g., a single StateFlow)
instead of multiple separate state variables.Required:
- Use *State, *Event, *Action
- Naming must be consistent (FeatureViewModel, FeatureState, FeatureEvent, FeatureAction)
- Follow unidirectional flow:
Action → ViewModel → State → UIInternal reducer/action architecture rules:
Async operations MUST NOT directly mutate UI state repeatedly inside
Flow collectors, suspend callbacks, or repository result handlers.Repository/network/database results MUST be converted into internal
actions usingsendAction(...).
handleAction(...)must act as the primary reducer responsible for:
- state mutation
- reducer-style state transitions
- triggering follow-up actions
Large async methods must be split into:
- async collection layer
- internal action dispatching
- reducer/state handling
Avoid directly calling another business/data-loading method from
repository collectors or async callbacks.
Prefer dispatching follow-up internal actions instead.Preferred pattern:
repository result
-> sendAction(...)
-> handleAction(...)
-> mutableStateFlow.update { ... }Anti-pattern examples:
mutableStateFlow.update { ... } inside collect { }
fetchX() -> directly calls fetchY() inside async collector
large methods mixing:
- collection
- state mutation
- navigation
- business chainingFlag:
- Multiple
mutableStateFlow.update {}calls inside collect { }- Direct state mutation inside async repository callbacks
- Async methods performing both collection and reducer logic
- Direct business-flow chaining from async collectors
- Missing internal reducer actions for async results
- Missing *State / *Event / *Action
- ViewModel not...
Files:
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.kt
🧠 Learnings (5)
📚 Learning: 2026-02-06T13:15:16.968Z
Learnt from: sahilshivekar
Repo: openMF/android-client PR: 2603
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanTransaction/LoanTransactionsViewModel.kt:43-106
Timestamp: 2026-02-06T13:15:16.968Z
Learning: Guideline: When a Kotlin function parameter is nullable (e.g., balance: Double?, currencyCode: String?, maximumFractionDigits: Int?) and downstream calls require a non-null value, add null-safety handling in all implementations. Specifically, avoid calling Currency.getInstance(currencyCode) with a possibly null currencyCode; provide a safe default (e.g., currencyCode ?: "$") or validate before use. Ensure all platform targets (Android/Desktop/Native) follow consistent null handling, and consider centralizing currencyCode normalization in the common layer if feasible. Add tests covering null currencyCode to prevent NPEs.
Applied to files:
core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/PaymentTypeMapper.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/di/UseCaseModule.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/GetLoanDisburseTemplateUseCase.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/CurrencyMapper.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseTemplate.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseNavigation.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseInput.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/LoanDisburseUseCase.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanDisburseRepository.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/loan/LoanDisburseMapper.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseState.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/di/LoanModule.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanDisburseRepositoryImpl.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountAction/LoanAccountActionNavigation.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/di/RepositoryModule.kt
📚 Learning: 2026-04-01T05:03:14.323Z
Learnt from: kartikey004
Repo: openMF/mifos-x-field-officer-app PR: 2659
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementScreen.kt:190-195
Timestamp: 2026-04-01T05:03:14.323Z
Learning: In this repo, existing `SelectableDates` / `SelectableDates.isSelectableDate(utcTimeMillis: Long)` implementations use `Clock.System.now().toEpochMilliseconds()` (UTC epoch millis) for date-boundary checks. During PR reviews, do not flag these checks for not using a timezone-aware `LocalDate` start-of-day approach; treat it as an established project-wide pattern. If a change is desired, handle it as a coordinated project-wide improvement rather than as a per-PR review issue.
Applied to files:
core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/PaymentTypeMapper.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/di/UseCaseModule.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/GetLoanDisburseTemplateUseCase.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/CurrencyMapper.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseTemplate.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseNavigation.ktcore/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseInput.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.ktcore/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/LoanDisburseUseCase.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanDisburseRepository.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/mappers/loan/LoanDisburseMapper.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseState.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/di/LoanModule.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanDisburseRepositoryImpl.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountAction/LoanAccountActionNavigation.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.ktcore/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.ktcore/data/src/commonMain/kotlin/com/mifos/core/data/di/RepositoryModule.kt
📚 Learning: 2026-07-08T13:55:15.322Z
Learnt from: sahilshivekar
Repo: openMF/mifos-x-field-officer-app PR: 2698
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/createGuarantor/CreateGuarantorViewModel.kt:366-397
Timestamp: 2026-07-08T13:55:15.322Z
Learning: In Kotlin ViewModels (e.g., using `mutableStateFlow` + `collect {}` to handle async results), it’s acceptable to directly update a single piece of state (and call `sendEvent`) inside the `collect {}` block for simple cases (e.g., updating one property like `searchedClientOptions`). Reserve the internal-action/reducer pattern (`sendAction(...)` + `handleAction`) for async results that affect multiple properties and/or require more complex state transitions, to avoid unnecessary ceremony for trivial cases.
Applied to files:
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseNavigation.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseState.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/di/LoanModule.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountAction/LoanAccountActionNavigation.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.ktfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt
📚 Learning: 2025-12-31T08:19:18.178Z
Learnt from: amanna13
Repo: openMF/android-client PR: 2569
File: core-base/designsystem/src/commonMain/kotlin/template/core/base/designsystem/layout/KptResponsiveLayout.kt:140-153
Timestamp: 2025-12-31T08:19:18.178Z
Learning: When syncing template code from kmp-project-template in the android-client repo, avoid introducing functional or behavioral fixes in the synced template code in the initial sync PR. Defer such fixes to follow-up issues to keep the PR focused on template syncing only. If a fix is necessary, create a separate follow-up issue/PR and document the scope so maintainers understand that changes are deferred to template-related refinement.
Applied to files:
core/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.kt
📚 Learning: 2026-03-16T11:58:32.496Z
Learnt from: sahilshivekar
Repo: openMF/mifos-x-field-officer-app PR: 2647
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt:96-96
Timestamp: 2026-03-16T11:58:32.496Z
Learning: In feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt (Kotlin/Compose Multiplatform), navigateToDashboard uses a direct method reference navController::navigateToLoanDashboardScreen without an ID guard. This is intentional: LoanAccountProfileScreen always provides a valid loanId, and LoanDashboardScreen handles invalid/missing data by showing a 'Failed to fetch Loan details' error state. Do not flag the absence of an ID guard here in future reviews.
Applied to files:
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt
🔇 Additional comments (30)
core/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.kt (1)
13-14: LGTM!Also applies to: 31-36, 342-343, 467-477
core/network/src/commonMain/kotlin/com/mifos/core/network/dto/CurrencyDto.kt (1)
1-24: LGTM!core/network/src/commonMain/kotlin/com/mifos/core/network/dto/PaymentTypeOptionDto.kt (1)
1-24: LGTM!core/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseRequestDto.kt (1)
1-29: LGTM!core/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/disburse/LoanDisburseResponseDto.kt (1)
1-22: LGTM!core/network/src/commonMain/kotlin/com/mifos/core/network/dto/loans/template/LoanDisburseTemplateDto.kt (1)
1-23: LGTM!feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseNavigation.kt (1)
1-39: LGTM!feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt (1)
16-17: LGTM!Also applies to: 39-40, 67-67, 137-137, 163-167
core/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.kt (1)
12-13: LGTM!Also applies to: 31-36, 73-74, 244-254
core/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseTemplate.kt (1)
15-20: LGTM!core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/CurrencyMapper.kt (1)
15-23: LGTM!feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseViewModel.kt (1)
41-51: MVI reducer shape is spot on.
loadTemplate/submitDisbursedispatch results throughsendAction(...)into a singlehandleActionreducer, with a singlemutableStateFlow, matching the required unidirectional Action → ViewModel → State → UI flow.Also applies to: 136-197, 199-221
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseScreen.kt (1)
76-137: Screen/Content split is clean.
LoanDisburseScreenhandles ViewModel wiring, state collection, and event-driven navigation only;LoanDisburseScreenContenttakes solelystate+ a singleonAction, matching the required two-layer structure.feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/di/LoanModule.kt (1)
26-26: LGTM!Also applies to: 55-55
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountAction/LoanAccountActionNavigation.kt (1)
23-31: LGTM!Also applies to: 53-53
core/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/loanDisburse/LoanDisburseInput.kt (1)
19-19: 🗄️ Data Integrity & IntegrationAlign
externalIdwith the API contract
LoanDisburseViewModelstill parses free-text input withtoIntOrNull(), so non-numeric external IDs are dropped unlessLoanDisburseRequestDto/ mapper logic uses the same type. Keep the contract consistent end-to-end.core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/PaymentTypeMapper.kt (1)
15-18: LGTM!core/data/src/commonMain/kotlin/com/mifos/core/data/mappers/loan/LoanDisburseMapper.kt (2)
19-32: LGTM!
34-39: LGTM!core/data/src/commonMain/kotlin/com/mifos/core/data/repository/loan/LoanDisburseRepository.kt (1)
16-21: LGTM!core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/loan/LoanDisburseRepositoryImpl.kt (1)
23-48: LGTM!core/domain/src/commonMain/kotlin/com/mifos/core/domain/di/UseCaseModule.kt (2)
99-100: LGTM!
190-191: LGTM!core/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/GetLoanDisburseTemplateUseCase.kt (1)
16-22: LGTM!core/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/loanDisburse/LoanDisburseUseCase.kt (1)
16-23: LGTM!core/data/src/commonMain/kotlin/com/mifos/core/data/di/RepositoryModule.kt (3)
80-80: LGTM!
153-153: LGTM!
206-206: LGTM!feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisburse/LoanDisburseState.kt (2)
18-50: LGTM!
52-52: LGTM!
|



Fixes - Jira-#681
Before
(Clicking on the Disburse option doesn't open the disburse screen as it wasn't implemented)

After
loan_disburse_success.mp4