Skip to content

Commit

Permalink
fix(usage-record): Use cint for casting additional_storage field
Browse files Browse the repository at this point in the history
- Python's int() will throw error for '10.0'
  • Loading branch information
tanmoysrt committed Dec 27, 2024
1 parent 8ca6e68 commit 0068699
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion press/press/doctype/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from frappe.core.utils import find, find_all
from frappe.installer import subprocess
from frappe.model.document import Document
from frappe.utils import cint
from frappe.utils.user import is_system_user

from press.agent import Agent
Expand Down Expand Up @@ -634,7 +635,7 @@ def create_subscription_for_storage(self, increment: int) -> None:
"Subscription",
existing_subscription.name,
"additional_storage",
increment + int(existing_subscription.additional_storage),
increment + cint(existing_subscription.additional_storage),
)
else:
frappe.get_doc(
Expand Down
3 changes: 2 additions & 1 deletion press/press/doctype/subscription/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import rq
from frappe.model.document import Document
from frappe.query_builder.functions import Coalesce, Count
from frappe.utils import cint

from press.overrides import get_permission_query_conditions_for_doctype
from press.press.doctype.site_plan.site_plan import SitePlan
Expand Down Expand Up @@ -151,7 +152,7 @@ def create_usage_record(self, date: DF.Date | None = None):
if self.additional_storage:
price = plan.price_inr if team.currency == "INR" else plan.price_usd
price_per_day = price / plan.period # no rounding off to avoid discrepancies
amount = price_per_day * int(self.additional_storage)
amount = price_per_day * cint(self.additional_storage)
else:
amount = plan.get_price_for_interval(self.interval, team.currency)

Expand Down

0 comments on commit 0068699

Please sign in to comment.