From 0068699080fdd859fc307312cc5d7d3e0f764ddc Mon Sep 17 00:00:00 2001 From: tanmoysrt <57363826+tanmoysrt@users.noreply.github.com> Date: Fri, 27 Dec 2024 10:33:19 +0530 Subject: [PATCH] fix(usage-record): Use cint for casting additional_storage field - Python's int() will throw error for '10.0' --- press/press/doctype/server/server.py | 3 ++- press/press/doctype/subscription/subscription.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/press/press/doctype/server/server.py b/press/press/doctype/server/server.py index 6631e40da9..cbdf82d9c9 100644 --- a/press/press/doctype/server/server.py +++ b/press/press/doctype/server/server.py @@ -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 @@ -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( diff --git a/press/press/doctype/subscription/subscription.py b/press/press/doctype/subscription/subscription.py index 3fa885d3df..562db0fb97 100644 --- a/press/press/doctype/subscription/subscription.py +++ b/press/press/doctype/subscription/subscription.py @@ -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 @@ -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)