1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-20 17:41:55 +02:00

Store note balances in a big integer

This commit is contained in:
Yohann D'ANELLO
2020-08-13 18:04:28 +02:00
parent 2d69e36adf
commit d98e46ffc2
4 changed files with 69 additions and 49 deletions

View File

@ -25,7 +25,7 @@ class Note(PolymorphicModel):
A Note can be searched find throught an :model:`note.Alias`
"""
balance = models.IntegerField(
balance = models.BigIntegerField(
verbose_name=_('account balance'),
help_text=_('in centimes, money credited for this instance'),
default=0,

View File

@ -196,9 +196,10 @@ class Transaction(PolymorphicModel):
# previously invalid
self.invalidity_reason = None
if source_balance > 2147483647 or source_balance < -2147483648\
or dest_balance > 2147483647 or dest_balance < -2147483648:
raise ValidationError(_("The note balances must be between - 21 474 836.47 € and 21 474 836.47."))
if source_balance > 9223372036854775807 or source_balance < -9223372036854775808\
or dest_balance > 9223372036854775807 or dest_balance < -9223372036854775808:
raise ValidationError(_("The note balances must be between - 92 233 720 368 547 758.08 "
"and 92 233 720 368 547 758.07 €."))
return source_balance - previous_source_balance, dest_balance - previous_dest_balance