Skip to content

fix(standing-instruction): reject non-positive and non-numeric amounts#2028

Open
bhuvan-somisetty wants to merge 1 commit into
openMF:devfrom
bhuvan-somisetty:fix/standing-instruction-amount-validation
Open

fix(standing-instruction): reject non-positive and non-numeric amounts#2028
bhuvan-somisetty wants to merge 1 commit into
openMF:devfrom
bhuvan-somisetty:fix/standing-instruction-amount-validation

Conversation

@bhuvan-somisetty

@bhuvan-somisetty bhuvan-somisetty commented May 12, 2026

Copy link
Copy Markdown

The amount validation in AddEditSIViewModel used any { !it.isDigit() } to catch invalid input, but isDigit() returns false for ., so any decimal amount like 10.50 was rejected with "Amount is Invalid" even though the amount field uses KeyboardType.Number which allows decimal separators.

Replaced the character-level digit check with toDoubleOrNull() == null for format validation, and added a <= 0 guard to reject zero and negative amounts. The null-path message is corrected to "Amount is Invalid" rather than the previous "Amount is Required".

Tested manually by entering 10.50, 0, -5, and abc in the standing instruction form to confirm each case is handled correctly.

Summary by CodeRabbit

  • Bug Fixes
    • Improved amount field validation in Standing Instructions to provide clearer error messages and prevent invalid amounts (zero or negative values).

Review Change Stack

@bhuvan-somisetty bhuvan-somisetty requested a review from a team May 12, 2026 06:56
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28b82a1a-f587-4012-a62e-b9c5754e4e94

📥 Commits

Reviewing files that changed from the base of the PR and between d399e0a and f30639e.

📒 Files selected for processing (1)
  • feature/standing-instruction/src/commonMain/kotlin/org/mifospay/feature/standing/instruction/createOrUpdate/AddEditSIViewModel.kt

📝 Walkthrough

Walkthrough

This PR updates amount validation in standing instruction creation to strengthen input validation. The change replaces digit-only checking with floating-point numeric parsing and adds a guard to reject zero or negative amounts.

Changes

Standing Instruction Amount Validation

Layer / File(s) Summary
Amount validation with numeric and positive checks
feature/standing-instruction/src/commonMain/kotlin/org/mifospay/feature/standing/instruction/createOrUpdate/AddEditSIViewModel.kt
Amount validation in add mode now uses toDoubleOrNull() to parse numeric input with "Amount is Invalid" error messaging, and rejects non-positive values with "Amount must be greater than 0".

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

A standing instruction stands tall and true,
When amounts are checked, both old and new.
No zeros creeping, no negatives here,
Just valid numbers, loud and clear! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and specifically describes the main change: fixing standing instruction amount validation to reject non-positive and non-numeric amounts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

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

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@niyajali

Copy link
Copy Markdown
Collaborator

Hi, @bhuvan-somisetty We appreciate your contribution. To facilitate seamless integration and collaboration, please ensure you have joined our Slack workspace and the relevant designated channel. We recommend thoroughly reviewing the bookmark pages, project README, and wiki to gain a comprehensive understanding of the project architecture and development guidelines. Active participation in the daily stand-up meetings is encouraged for discussions, ticket assignments, and to foster connections with the development team. Prior to requesting an assignment in the channel, please create a Jira ticket or ask for an assignment of existing tickets. All pull request descriptions must comprehensively detail the before and after changes, substantiated by relevant video or image evidence.

Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
@bhuvan-somisetty bhuvan-somisetty force-pushed the fix/standing-instruction-amount-validation branch from 60825e7 to b36cf44 Compare July 5, 2026 05:59
@bhuvan-somisetty

Copy link
Copy Markdown
Author

Thanks for the pointers - I'll make sure to join the Slack workspace and the project channel, and go through the README/wiki and Jira board before picking up further work. Rebased this PR onto latest dev in the meantime; the fix and manual test steps are described above (10.50 / 0 / -5 / abc cases). Happy to add anything else needed for review.

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