Skip to content

Commit

Permalink
Update decimal places and max digits
Browse files Browse the repository at this point in the history
Supercedes dj-stripe#1786
  • Loading branch information
jleclanche committed Aug 29, 2023
1 parent ac1cc35 commit 8f2f30c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
7 changes: 2 additions & 5 deletions djstripe/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@ class StripeDecimalCurrencyAmountField(FieldDeconstructMixin, models.DecimalFiel
"""

def __init__(self, *args, **kwargs):
"""
Assign default args to this field. By contacting stripe support, some accounts
will have their limit raised to 11 digits
"""
defaults = {"decimal_places": 2, "max_digits": 11}
# see https://github.com/dj-stripe/dj-stripe/pull/1786
defaults = {"decimal_places": 2, "max_digits": 14}
defaults.update(kwargs)
super().__init__(*args, **defaults)

Expand Down
8 changes: 4 additions & 4 deletions djstripe/models/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,8 +1198,8 @@ class InvoiceItem(StripeModel):
unit_amount_decimal = StripeDecimalCurrencyAmountField(
null=True,
blank=True,
max_digits=19,
decimal_places=12,
max_digits=djstripe_settings.decimal_max_digits,
decimal_places=djstripe_settings.decimal_places,
help_text=(
"Same as `unit_amount`, but contains a decimal value with "
"at most 12 decimal places."
Expand Down Expand Up @@ -1526,8 +1526,8 @@ class Plan(StripeModel):
amount_decimal = StripeDecimalCurrencyAmountField(
null=True,
blank=True,
max_digits=19,
decimal_places=12,
max_digits=djstripe_settings.decimal_max_digits,
decimal_places=djstripe_settings.decimal_places,
help_text=(
"The unit amount in cents to be charged, represented as a decimal "
"string with at most 12 decimal places."
Expand Down
4 changes: 2 additions & 2 deletions djstripe/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2282,8 +2282,8 @@ class Price(StripeModel):
unit_amount_decimal = StripeDecimalCurrencyAmountField(
null=True,
blank=True,
max_digits=19,
decimal_places=12,
max_digits=djstripe_settings.decimal_max_digits,
decimal_places=djstripe_settings.decimal_places,
help_text=(
"The unit amount in cents to be charged, represented as a decimal "
"string with at most 12 decimal places."
Expand Down
8 changes: 8 additions & 0 deletions djstripe/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def get_idempotency_key(self):
"DJSTRIPE_IDEMPOTENCY_KEY_CALLBACK", self._get_idempotency_key
)

@property
def decimal_max_digits(self):
return 24

@property
def decimal_places(self):
return 12

@property
def DJSTRIPE_WEBHOOK_URL(self):
return getattr(settings, "DJSTRIPE_WEBHOOK_URL", r"^webhook/$")
Expand Down

0 comments on commit 8f2f30c

Please sign in to comment.