Skip to content

Commit

Permalink
Fix hours per period bug
Browse files Browse the repository at this point in the history
Was asking for the value, even when it wasn't needed.
  • Loading branch information
BryceStevenWilley committed Nov 30, 2023
1 parent afcd4dc commit 48375fc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions docassemble/ALToolbox/al_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,26 +1035,26 @@ 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
value = item.total()

# Use the appropriate calculation
if is_hourly:
# 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

return (
value * Decimal(hours_per_period) * Decimal(frequency_to_use)
) / Decimal(times_per_year)
Expand Down

0 comments on commit 48375fc

Please sign in to comment.