Skip to content

Commit

Permalink
Merge pull request #191 from K-w-e/bugfix/185
Browse files Browse the repository at this point in the history
Handle transaction lower than 1
  • Loading branch information
mikev-cw authored Jan 16, 2025
2 parents 87342c1 + 4c2e177 commit dc89ae8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/pages/add_page/add_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ class _AddPageState extends ConsumerState<AddPage> with Functions {
// Remove all non-numeric characters
var cleanNumberString = amountController.text.replaceAll(RegExp(r'[^0-9\.]'), '');

// Remove leading zeros
return cleanNumberString.replaceAll(RegExp(r'^[0\.]+(?=.)'), '');
// Remove leading zeros only if the number does not start with "0."
if (!cleanNumberString.startsWith('0.')) {
cleanNumberString = cleanNumberString.replaceAll(RegExp(r'^0+(?!\.)'), '');
}

if (cleanNumberString.startsWith('.')) {
cleanNumberString = '0$cleanNumberString';
}

return cleanNumberString;
}

void _updateAmount() {
Expand Down

0 comments on commit dc89ae8

Please sign in to comment.