Skip to content

Conversation

sam-arth07
Copy link
Contributor

@sam-arth07 sam-arth07 commented Oct 4, 2025

Fixes - Jira-#538

Screen Recording:

chargePage.mp4

After Update:

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

@Nagarjuna0033
Copy link
Contributor

image after opening bottom sheet without entering any amount it is showing error message.

val fieldOfficerOptions: List<FieldOfficerOptions>? = null,

@IgnoredOnParcel
val chargeOptions: List<ChargeOptions>? = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

remove @IgnoreOnParcel annotation

Comment on lines 60 to 62
confirmValueChange = { newValue ->
newValue != SheetValue.Hidden
},
Copy link
Contributor

Choose a reason for hiding this comment

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

The confirmValueChange callback blocks the sheet from reaching Hidden, preventing swipe-down dismissal and breaking standard Material Design UX.

Suggestion: Remove confirmValueChange or allow dismissal.

Suggested change
confirmValueChange = { newValue ->
newValue != SheetValue.Hidden
},
confirmValueChange = { newValue ->
true // Allow all state changes
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intentionally added that to prevent the Bottom Sheet from accidentally dismissing when scrolling through view charges, as that too seems like a bad UX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a screen Recording highlighting the issue i m trying to mention:

Screen_recording_20251008_214517.webm

} else {
state.savingsProductTemplate?.chargeOptions?.get(state.chooseChargeIndex)?.name ?: ""
},
selectedDate = if (state.chargeDate >= DateHelper.getDateAsStringFromLong(Clock.System.now().toEpochMilliseconds())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Dates are compared as strings using >=, which may produce incorrect results since string comparison is lexicographic, not chronological.

Suggested fix: Try using epoch milliseconds itself for comparison.

selectedChargeName = if (state.chooseChargeIndex == -1) {
""
} else {
state.savingsProductTemplate?.chargeOptions?.get(state.chooseChargeIndex)?.name ?: ""
Copy link
Contributor

@biplab1 biplab1 Oct 7, 2025

Choose a reason for hiding this comment

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

List access occurs without verifying index bounds, which may cause crashes.

Suggested fix: Use safe access.

Suggested change
state.savingsProductTemplate?.chargeOptions?.get(state.chooseChargeIndex)?.name ?: ""
state.savingsProductTemplate?.chargeOptions?.getOrNull(state.chooseChargeIndex)?.name ?: ""

chargeCollectedOn = if (state.chooseChargeIndex == -1) {
""
} else {
state.savingsProductTemplate?.chargeOptions?.get(state.chooseChargeIndex)?.chargeTimeType?.value ?: ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, please review.

import com.mifos.core.model.objects.account.loan.Currency
import com.mifos.core.model.objects.account.saving.FieldOfficerOptions
import com.mifos.core.model.objects.commonfiles.InterestType
import com.mifos.core.model.objects.template.loan.ChargeOptions
Copy link
Contributor

Choose a reason for hiding this comment

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

Imports loan.ChargeOptions in a savings-related class. This is semantically incorrect and may cause confusion or issues later.

Suggested fix:
Verify if client.ChargeOptions or a savings-specific version should be used instead.

input.count { it == '.' } > 1 -> Res.string.error_invalid_number
input.any { !it.isDigit() && it != '.' } -> Res.string.error_digits_only
input.toDoubleOrNull() == null -> Res.string.error_invalid_number
input.toDouble() == 0.0 -> Res.string.error_number_zero
Copy link
Contributor

Choose a reason for hiding this comment

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

Direct floating-point equality check (input.toDouble() == 0.0) may cause precision problems.

Suggested fix:
Compare as strings or safely parse as shown below:

input == "0" || input == "0.0" || input.toDoubleOrNull() == 0.0

Copy link
Contributor

@biplab1 biplab1 Oct 7, 2025

Choose a reason for hiding this comment

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

doubleNumberValidator treats blank input as valid while numberValidator flags it as an error. This inconsistency can confuse developers.

Suggested fix:
Add a required: Boolean flag or clarify the intended behavior through documentation.

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.

@therajanmaurya therajanmaurya merged commit bb4e8b8 into openMF:development Oct 8, 2025
2 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.

4 participants