dj-stripe / dj-stripe

dj-stripe automatically syncs your Stripe Data to your local database as pre-implemented Django Models allowing you to use the Django ORM, in your code, to work with the data making it easier and faster.

Home Page:https://dj-stripe.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Billing.unit_amount_decimal returns a database error if the value is more than 7 digits

mistalaba opened this issue · comments

Describe the bug
models.Billing.unit_amount_decimal is set to

    unit_amount_decimal = StripeDecimalCurrencyAmountField(
        null=True,
        blank=True,
        max_digits=19,
        decimal_places=12,
        help_text=(
            "Same as `unit_amount`, but contains a decimal value with "
            "at most 12 decimal places."
        ),
    )

This breaks if the input value is for example 10000000 (100,000.00) because of the max_digits, which should be higher that 19. This seems to be fixed in the master branch where you are using max_digits=djstripe_settings.decimal_max_digits (set to 24 instead of 19) and decimal_places=djstripe_settings.decimal_places instead. I'm sorry for not giving more details, I don't have access to our project using dj-stripe right now 🙏

To Reproduce
Add a billing instance and set unit_amount_decimal to a value with more than 7 digits.

Software versions

  • Dj-Stripe version: 2.8.2
  • Python version: 3.11
  • Django version: 4.2.5

@mistalaba Please refer to the discussion here

Closing this issue as there is already a discussion on this.