Skip to content

Commit

Permalink
Fixed bug when adding a trade without fees or sdr (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilcardella committed Mar 14, 2020
1 parent 3d4a33a commit 0062bba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## []
### Fixed
- Bug preventing to add a trade with fee equal to zero

### Changed
- Updated Pipfile unifying packages and adding custom scripts
- Grouped icons in the header bar under one single popover menu
Expand Down
10 changes: 6 additions & 4 deletions src/UI/gtk/AddTradeWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ def _check_data_validity(self):
not self._price_entry.get_sensitive()
or self._is_float_valid(self._price_entry.get_text()),
not self._fee_entry.get_sensitive()
or self._is_float_valid(self._fee_entry.get_text()),
or self._is_float_valid(self._fee_entry.get_text(), zero_ok=True),
not self._sdr_entry.get_sensitive()
or self._is_float_valid(self._sdr_entry.get_text()),
or self._is_float_valid(self._sdr_entry.get_text(), zero_ok=True),
not self._notes_entry.get_sensitive()
or self._is_string_valid(self._notes_entry.get_text(), empty_ok=True),
]
Expand All @@ -245,10 +245,12 @@ def _is_string_valid(self, string_value, empty_ok=False):
except:
return False

def _is_float_valid(self, string_value):
def _is_float_valid(self, string_value, zero_ok=False):
try:
f = float(string_value)
return True if f > 0.0 else False
if f > 0.0 or (f == 0.0 and zero_ok):
return True
return False
except:
return False

Expand Down

0 comments on commit 0062bba

Please sign in to comment.