From dff9f97f1d9995d935ed736ee550679a5140ca0e Mon Sep 17 00:00:00 2001 From: mackenzie Date: Fri, 25 Oct 2024 13:25:47 -0700 Subject: [PATCH] back to using modf with rounding --- src/vendor/processors/stripe.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/vendor/processors/stripe.py b/src/vendor/processors/stripe.py index 4f1b0d18..6a305665 100644 --- a/src/vendor/processors/stripe.py +++ b/src/vendor/processors/stripe.py @@ -1,6 +1,7 @@ import json import logging from decimal import Decimal, ROUND_UP +from math import modf import stripe from django.conf import settings @@ -350,15 +351,11 @@ def convert_decimal_to_integer(self, decimal): if decimal == 0: return 0 - fraction_part = decimal % 1 - whole_part = decimal - fraction_part + fraction_part, whole_part = modf(decimal) rounded_fraction = round(fraction_part, 2) whole_str = str(whole_part).split('.')[0] - if fraction_part == 0: - fraction_str = "00" - else: - fraction_str = str(rounded_fraction).split('.')[1][:2] + fraction_str = str(rounded_fraction).split('.')[1][:2] if len(fraction_str) < 2: fraction_str = fraction_str + "0"