Increase size of monetary decimal fields

This commit is contained in:
Raphael Michel
2023-03-16 21:26:37 +01:00
parent e9ab0d8654
commit 4c9640561c
19 changed files with 248 additions and 65 deletions

View File

@@ -116,7 +116,7 @@ class Discount(LoggedModel):
condition_min_value = models.DecimalField(
verbose_name=_('Minimum gross value of matching products'),
decimal_places=2,
max_digits=10,
max_digits=13,
default=Decimal('0.00'),
)

View File

@@ -129,7 +129,7 @@ class GiftCardTransaction(models.Model):
)
value = models.DecimalField(
decimal_places=2,
max_digits=10
max_digits=13
)
order = models.ForeignKey(
'Order',

View File

@@ -152,7 +152,7 @@ class Invoice(models.Model):
footer_text = models.TextField(blank=True)
foreign_currency_display = models.CharField(max_length=50, null=True, blank=True)
foreign_currency_rate = models.DecimalField(decimal_places=4, max_digits=10, null=True, blank=True)
foreign_currency_rate = models.DecimalField(decimal_places=4, max_digits=13, null=True, blank=True)
foreign_currency_rate_date = models.DateField(null=True, blank=True)
foreign_currency_source = models.CharField(max_length=100, null=True, blank=True)
@@ -347,8 +347,8 @@ class InvoiceLine(models.Model):
invoice = models.ForeignKey('Invoice', related_name='lines', on_delete=models.CASCADE)
position = models.PositiveIntegerField(default=0)
description = models.TextField()
gross_value = models.DecimalField(max_digits=10, decimal_places=2)
tax_value = models.DecimalField(max_digits=10, decimal_places=2, default=Decimal('0.00'))
gross_value = models.DecimalField(max_digits=13, decimal_places=2)
tax_value = models.DecimalField(max_digits=13, decimal_places=2, default=Decimal('0.00'))
tax_rate = models.DecimalField(max_digits=7, decimal_places=2, default=Decimal('0.00'))
tax_name = models.CharField(max_length=190)
subevent = models.ForeignKey('SubEvent', null=True, blank=True, on_delete=models.PROTECT)

View File

@@ -164,7 +164,7 @@ class SubEventItem(models.Model):
"""
subevent = models.ForeignKey('SubEvent', on_delete=models.CASCADE)
item = models.ForeignKey('Item', on_delete=models.CASCADE)
price = models.DecimalField(max_digits=7, decimal_places=2, null=True, blank=True)
price = models.DecimalField(max_digits=13, decimal_places=2, null=True, blank=True)
disabled = models.BooleanField(default=False, verbose_name=_('Disable product for this date'))
available_from = models.DateTimeField(
verbose_name=_("Available from"),
@@ -220,7 +220,7 @@ class SubEventItemVariation(models.Model):
"""
subevent = models.ForeignKey('SubEvent', on_delete=models.CASCADE)
variation = models.ForeignKey('ItemVariation', on_delete=models.CASCADE)
price = models.DecimalField(max_digits=7, decimal_places=2, null=True, blank=True)
price = models.DecimalField(max_digits=13, decimal_places=2, null=True, blank=True)
disabled = models.BooleanField(default=False, verbose_name=_('Disable product for this date'))
available_from = models.DateTimeField(
verbose_name=_("Available from"),
@@ -407,7 +407,7 @@ class Item(LoggedModel):
help_text=_("If this product has multiple variations, you can set different prices for each of the "
"variations. If a variation does not have a special price or if you do not have variations, "
"this price will be used."),
max_digits=7, decimal_places=2, null=True
max_digits=13, decimal_places=2, null=True
)
free_price = models.BooleanField(
default=False,
@@ -538,7 +538,7 @@ class Item(LoggedModel):
original_price = models.DecimalField(
verbose_name=_('Original price'),
blank=True, null=True,
max_digits=7, decimal_places=2,
max_digits=13, decimal_places=2,
help_text=_('If set, this will be displayed next to the current price to show that the current price is a '
'discounted one. This is just a cosmetic setting and will not actually impact pricing.')
)
@@ -952,14 +952,14 @@ class ItemVariation(models.Model):
verbose_name=_("Position")
)
default_price = models.DecimalField(
decimal_places=2, max_digits=7,
decimal_places=2, max_digits=13,
null=True, blank=True,
verbose_name=_("Default price"),
)
original_price = models.DecimalField(
verbose_name=_('Original price'),
blank=True, null=True,
max_digits=7, decimal_places=2,
max_digits=13, decimal_places=2,
help_text=_('If set, this will be displayed next to the current price to show that the current price is a '
'discounted one. This is just a cosmetic setting and will not actually impact pricing.')
)
@@ -1304,7 +1304,7 @@ class ItemBundle(models.Model):
)
designated_price = models.DecimalField(
default=Decimal('0.00'), blank=True,
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
verbose_name=_('Designated price part'),
help_text=_('If set, it will be shown that this bundled item is responsible for the given value of the total '
'gross price. This might be important in cases of mixed taxation, but can be kept blank otherwise. This '

View File

@@ -220,7 +220,7 @@ class Order(LockModel, LoggedModel):
verbose_name=_("Expiration date")
)
total = models.DecimalField(
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
verbose_name=_("Total amount")
)
comment = models.TextField(
@@ -403,8 +403,8 @@ class Order(LockModel, LoggedModel):
state__in=(OrderRefund.REFUND_STATE_CREATED, OrderRefund.REFUND_STATE_TRANSIT),
order=OuterRef('pk')
)
payment_sum_sq = Subquery(payment_sum, output_field=models.DecimalField(decimal_places=2, max_digits=10))
refund_sum_sq = Subquery(refund_sum, output_field=models.DecimalField(decimal_places=2, max_digits=10))
payment_sum_sq = Subquery(payment_sum, output_field=models.DecimalField(decimal_places=2, max_digits=13))
refund_sum_sq = Subquery(refund_sum, output_field=models.DecimalField(decimal_places=2, max_digits=13))
if sums:
qs = qs.annotate(
payment_sum=payment_sum_sq,
@@ -1313,7 +1313,7 @@ class AbstractPosition(models.Model):
on_delete=models.PROTECT
)
price = models.DecimalField(
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
verbose_name=_("Price")
)
attendee_name_cached = models.CharField(
@@ -1545,7 +1545,7 @@ class OrderPayment(models.Model):
max_length=190, choices=PAYMENT_STATES
)
amount = models.DecimalField(
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
verbose_name=_("Amount")
)
order = models.ForeignKey(
@@ -1929,7 +1929,7 @@ class OrderRefund(models.Model):
max_length=190, choices=REFUND_SOURCES
)
amount = models.DecimalField(
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
verbose_name=_("Amount")
)
order = models.ForeignKey(
@@ -2078,7 +2078,7 @@ class OrderFee(models.Model):
)
value = models.DecimalField(
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
verbose_name=_("Value")
)
order = models.ForeignKey(
@@ -2102,7 +2102,7 @@ class OrderFee(models.Model):
null=True, blank=True
)
tax_value = models.DecimalField(
max_digits=10, decimal_places=2,
max_digits=13, decimal_places=2,
verbose_name=_('Tax value')
)
canceled = models.BooleanField(default=False)
@@ -2236,7 +2236,7 @@ class OrderPosition(AbstractPosition):
)
voucher_budget_use = models.DecimalField(
max_digits=10, decimal_places=2, null=True, blank=True,
max_digits=13, decimal_places=2, null=True, blank=True,
)
tax_rate = models.DecimalField(
@@ -2249,7 +2249,7 @@ class OrderPosition(AbstractPosition):
null=True, blank=True
)
tax_value = models.DecimalField(
max_digits=10, decimal_places=2,
max_digits=13, decimal_places=2,
verbose_name=_('Tax value')
)
@@ -2670,7 +2670,7 @@ class Transaction(models.Model):
verbose_name=pgettext_lazy("subevent", "Date"),
)
price = models.DecimalField(
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
verbose_name=_("Price")
)
tax_rate = models.DecimalField(
@@ -2683,7 +2683,7 @@ class Transaction(models.Model):
null=True, blank=True
)
tax_value = models.DecimalField(
max_digits=10, decimal_places=2,
max_digits=13, decimal_places=2,
verbose_name=_('Tax value')
)
fee_type = models.CharField(
@@ -2761,19 +2761,19 @@ class CartPosition(AbstractPosition):
verbose_name=_('Tax rate')
)
listed_price = models.DecimalField(
decimal_places=2, max_digits=10, null=True,
decimal_places=2, max_digits=13, null=True,
)
price_after_voucher = models.DecimalField(
decimal_places=2, max_digits=10, null=True,
decimal_places=2, max_digits=13, null=True,
)
custom_price_input = models.DecimalField(
decimal_places=2, max_digits=10, null=True,
decimal_places=2, max_digits=13, null=True,
)
custom_price_input_is_net = models.BooleanField(
default=False,
)
line_price_gross = models.DecimalField(
decimal_places=2, max_digits=10, null=True,
decimal_places=2, max_digits=13, null=True,
)
requested_valid_from = models.DateTimeField(
null=True,
@@ -3056,7 +3056,7 @@ class CachedCombinedTicket(models.Model):
class CancellationRequest(models.Model):
order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name='cancellation_requests')
created = models.DateTimeField(auto_now_add=True)
cancellation_fee = models.DecimalField(max_digits=10, decimal_places=2)
cancellation_fee = models.DecimalField(max_digits=13, decimal_places=2)
refund_as_giftcard = models.BooleanField(default=False)

View File

@@ -213,7 +213,7 @@ class Voucher(LoggedModel):
verbose_name=_("Maximum discount budget"),
help_text=_("This is the maximum monetary amount that will be discounted using this voucher across all usages. "
"If this is sum reached, the voucher can no longer be used."),
decimal_places=2, max_digits=10,
decimal_places=2, max_digits=13,
null=True, blank=True
)
valid_until = models.DateTimeField(
@@ -243,7 +243,7 @@ class Voucher(LoggedModel):
)
value = models.DecimalField(
verbose_name=_("Voucher value"),
decimal_places=2, max_digits=10, null=True, blank=True,
decimal_places=2, max_digits=13, null=True, blank=True,
)
item = models.ForeignKey(
Item, related_name='vouchers',
@@ -599,7 +599,7 @@ class Voucher(LoggedModel):
Order.STATUS_PENDING
]
).order_by().values('voucher_id').annotate(s=Sum('voucher_budget_use')).values('s')
return qs.annotate(budget_used_orders=Coalesce(Subquery(opq, output_field=models.DecimalField(max_digits=10, decimal_places=2)), Decimal('0.00')))
return qs.annotate(budget_used_orders=Coalesce(Subquery(opq, output_field=models.DecimalField(max_digits=13, decimal_places=2)), Decimal('0.00')))
def budget_used(self):
ops = OrderPosition.objects.filter(