Skip to content

Commit

Permalink
Put if logic to check if twelve_month_price is 0 to stop error of amo…
Browse files Browse the repository at this point in the history
…unt / twelve_month_price

I set value but set it to 0 if it doesnt find a value:
twelve_month_price = pricing_section.get('12Month', 0)

The error occured when this line ran when twelve_month_price could not find a value and set 0 to value instead
if amount > twelve_month_price:

I added a if statement to skip this section as if the twelve_month_price isnt set then likely longer subscriptions are not allowed.
  if twelve_month_price != 0:
  • Loading branch information
mtrogman committed Dec 5, 2024
1 parent e1dd377 commit 65128c3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/mathFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ def calculate_term_length(server, amount, is_4k):
return 1

# Check if the amount covers multiple years
if amount > twelve_month_price:
years_paid_for = amount / twelve_month_price
if years_paid_for.is_integer():
return int(years_paid_for * 12) # Convert years to months
if twelve_month_price != 0:
if amount > twelve_month_price:
years_paid_for = amount / twelve_month_price
if years_paid_for.is_integer():
return int(years_paid_for * 12) # Convert years to months

# Mixed payment scenario: Iteratively calculate possible month combinations
term_length = 0
Expand Down

0 comments on commit 65128c3

Please sign in to comment.