Skip to content

Commit

Permalink
back to using modf with rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcamisa committed Oct 25, 2024
1 parent e835169 commit dff9f97
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/vendor/processors/stripe.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit dff9f97

Please sign in to comment.