diff --git a/games/models.py b/games/models.py index 18cab6f..89cf3a6 100644 --- a/games/models.py +++ b/games/models.py @@ -164,6 +164,16 @@ class Purchase(models.Model): raise ValidationError( f"{self.get_type_display()} must have a related purchase." ) + if self.pk is not None: + # Retrieve the existing instance from the database + existing_purchase = Purchase.objects.get(pk=self.pk) + # If price has changed, reset converted fields + if ( + existing_purchase.price != self.price + or existing_purchase.price_currency != self.price_currency + ): + self.converted_price = None + self.converted_currency = None super().save(*args, **kwargs)