diff --git a/app_users/admin.py b/app_users/admin.py index 6d5896352..d762fbd11 100644 --- a/app_users/admin.py +++ b/app_users/admin.py @@ -131,6 +131,7 @@ class AppUserTransactionAdmin(admin.ModelAdmin): "created_at", "end_balance", "type", + "dollar_amt", ] readonly_fields = ["created_at"] list_filter = ["created_at", IsStripeFilter] diff --git a/app_users/migrations/0014_appusertransaction_dollar_amt.py b/app_users/migrations/0014_appusertransaction_dollar_amt.py new file mode 100644 index 000000000..f38d9aaa6 --- /dev/null +++ b/app_users/migrations/0014_appusertransaction_dollar_amt.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.5 on 2023-12-27 20:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("app_users", "0013_alter_appusertransaction_type"), + ] + + operations = [ + migrations.AddField( + model_name="appusertransaction", + name="dollar_amt", + field=models.DecimalField(decimal_places=2, default=0.0, max_digits=6), + ), + ] diff --git a/app_users/models.py b/app_users/models.py index fa7e5b931..441e0b4d3 100644 --- a/app_users/models.py +++ b/app_users/models.py @@ -137,13 +137,14 @@ def add_balance(self, amount: int, invoice_id: str) -> "AppUserTransaction": user: AppUser = AppUser.objects.select_for_update().get(pk=self.pk) user.balance += amount user.save(update_fields=["balance"]) - + dollar_amt = amount / 100 return AppUserTransaction.objects.create( user=self, invoice_id=invoice_id, amount=amount, end_balance=user.balance, type=type, + dollar_amt=dollar_amt, ) def copy_from_firebase_user(self, user: auth.UserRecord) -> "AppUser": @@ -231,6 +232,7 @@ class AppUserTransaction(models.Model): end_balance = models.IntegerField() created_at = models.DateTimeField(editable=False, blank=True, default=timezone.now) type = models.CharField(max_length=255, default="Stripe") + dollar_amt = models.DecimalField(max_digits=6, decimal_places=2, default=0.0) class Meta: verbose_name = "Transaction"