Skip to content

Commit

Permalink
Ensure that hours_per_period is a number
Browse files Browse the repository at this point in the history
Not unstructured text.
  • Loading branch information
BryceStevenWilley committed Sep 26, 2023
1 parent ce73d2e commit 7bdc847
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docassemble/ALToolbox/al_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,14 @@ def _item_value_per_times_per_year(
else:
frequency_to_use = self.times_per_year

# NOTE: fixes a bug that was present < 0.8.2
try :
hours_per_period = Decimal(self.hours_per_period)
except:
log(word("Your hours per period need to be just a single number, without words"), "danger")
delattr(self, "hours_per_period")
self.hours_per_period # Will cause another exception

# Both the job and the item itself need to be hourly to be
# calculated as hourly
is_hourly = self.is_hourly and hasattr(item, "is_hourly") and item.is_hourly
Expand All @@ -1036,7 +1044,7 @@ def _item_value_per_times_per_year(
# Use the appropriate calculation
if is_hourly:
return (
value * Decimal(self.hours_per_period) * Decimal(frequency_to_use)
value * Decimal(hours_per_period) * Decimal(frequency_to_use)
) / Decimal(times_per_year)
else:
return (value * Decimal(frequency_to_use)) / Decimal(times_per_year)
Expand Down

0 comments on commit 7bdc847

Please sign in to comment.