Skip to content

Commit

Permalink
Fixed regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
JJtan2002 committed Jun 24, 2024
1 parent e5aa6cd commit edbd6f7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.6 on 2024-06-23 17:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('budget_tracking', '0002_alter_transaction_update_wallet'),
]

operations = [
migrations.AddField(
model_name='customlabel',
name='current_amount',
field=models.DecimalField(decimal_places=2, default=0, max_digits=15),
),
migrations.AddField(
model_name='customlabel',
name='goal',
field=models.DecimalField(decimal_places=2, default=0, max_digits=15),
),
migrations.AddField(
model_name='customlabel',
name='is_monthly',
field=models.BooleanField(default=True),
),
]
4 changes: 2 additions & 2 deletions backend/budget_tracking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ def save(self, is_first_save=False, **kwargs):
amount = self.value if self.type == 'Earning' else (-self.value)
self.wallet.update_balance(amount)

if self.is_within_current_month() and self.label.is_monthly:
if self.label and self.is_within_current_month() and self.label.is_monthly:
self.label.update_balance(self.value)

if not self.label.is_monthly:
if self.label and not self.label.is_monthly:
self.label.update_balance(self.value)

return super().save(**kwargs)
Expand Down
20 changes: 10 additions & 10 deletions backend/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ def create_user(self, name, email, password=None):
user.save(using=self._db)

labels_data = [
{"id": 0, "name": "Food", "color": "white"},
{"id": 1, "name": "Transportation", "color": "black"},
{"id": 2, "name": "Housing", "color": "white"},
{"id": 3, "name": "Utilities", "color": "black"},
{"id": 4, "name": "Entertainment", "color": "white"},
{"id": 5, "name": "Salary", "color": "black"},
{"id": 6, "name": "Freelance Income", "color": "white"},
{"id": 7, "name": "Investment", "color": "black"},
{"id": 8, "name": "Gifts", "color": "white"},
{"id": 9, "name": "Other", "color": "black"},
{"id": 0, "name": "Food", "color": "white", "is_monthly" : True},
{"id": 1, "name": "Transportation", "color": "black", "is_monthly" : True},
{"id": 2, "name": "Housing", "color": "white", "is_monthly" : True},
{"id": 3, "name": "Utilities", "color": "black", "is_monthly" : True},
{"id": 4, "name": "Entertainment", "color": "white", "is_monthly" : True},
{"id": 5, "name": "Salary", "color": "black", "is_monthly" : True},
{"id": 6, "name": "Freelance Income", "color": "white", "is_monthly" : True},
{"id": 7, "name": "Investment", "color": "black", "is_monthly" : True},
{"id": 8, "name": "Gifts", "color": "white", "is_monthly" : True},
{"id": 9, "name": "Other", "color": "black", "is_monthly" : True},
]

# Creation of a related wallet for the created user
Expand Down

0 comments on commit edbd6f7

Please sign in to comment.