summaryrefslogtreecommitdiff
path: root/app/budget
diff options
context:
space:
mode:
Diffstat (limited to 'app/budget')
-rw-r--r--app/budget/0007_luxpurchase_cat.py20
-rw-r--r--app/budget/migrations/0005_luxspendingcategory_luxfixedmonthly.py33
-rw-r--r--app/budget/migrations/0006_remove_luxfixedmonthly_cat_and_more.py23
-rw-r--r--app/budget/migrations/0007_luxpurchase_cat.py19
-rw-r--r--app/budget/models.py22
5 files changed, 106 insertions, 11 deletions
diff --git a/app/budget/0007_luxpurchase_cat.py b/app/budget/0007_luxpurchase_cat.py
new file mode 100644
index 0000000..b7bb553
--- /dev/null
+++ b/app/budget/0007_luxpurchase_cat.py
@@ -0,0 +1,20 @@
+# Generated by Django 4.0.6 on 2022-11-12 12:53
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('budget', '0006_remove_luxfixedmonthly_cat_and_more'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='luxpurchase',
+ name='cat',
+ field=models.ForeignKey(default='Grocery & Home', on_delete=django.db.models.deletion.CASCADE, to='budget.luxspendingcategory'),
+ preserve_default=False,
+ ),
+ ]
diff --git a/app/budget/migrations/0005_luxspendingcategory_luxfixedmonthly.py b/app/budget/migrations/0005_luxspendingcategory_luxfixedmonthly.py
new file mode 100644
index 0000000..66af470
--- /dev/null
+++ b/app/budget/migrations/0005_luxspendingcategory_luxfixedmonthly.py
@@ -0,0 +1,33 @@
+# Generated by Django 4.0.6 on 2022-11-12 12:52
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('budget', '0004_alter_luxpurchase_source'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='LuxSpendingCategory',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=200)),
+ ('date_recorded', models.DateTimeField(auto_now_add=True)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='LuxFixedMonthly',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=200)),
+ ('category', models.IntegerField(choices=[(0, 'Grocery & Home'), (1, 'Gas'), (2, 'Bus'), (3, 'Lodging'), (4, 'Books'), (5, 'Clothes'), (6, 'Eating Out'), (7, 'Misc')], default=0)),
+ ('date_recorded', models.DateTimeField(auto_now_add=True)),
+ ('cat', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='budget.luxspendingcategory')),
+ ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='budget.luxsource')),
+ ],
+ ),
+ ]
diff --git a/app/budget/migrations/0006_remove_luxfixedmonthly_cat_and_more.py b/app/budget/migrations/0006_remove_luxfixedmonthly_cat_and_more.py
new file mode 100644
index 0000000..3631cc3
--- /dev/null
+++ b/app/budget/migrations/0006_remove_luxfixedmonthly_cat_and_more.py
@@ -0,0 +1,23 @@
+# Generated by Django 4.0.6 on 2022-11-12 12:53
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('budget', '0005_luxspendingcategory_luxfixedmonthly'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='luxfixedmonthly',
+ name='cat',
+ ),
+ migrations.AlterField(
+ model_name='luxfixedmonthly',
+ name='category',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='budget.luxspendingcategory'),
+ ),
+ ]
diff --git a/app/budget/migrations/0007_luxpurchase_cat.py b/app/budget/migrations/0007_luxpurchase_cat.py
new file mode 100644
index 0000000..7a8e548
--- /dev/null
+++ b/app/budget/migrations/0007_luxpurchase_cat.py
@@ -0,0 +1,19 @@
+# Generated by Django 4.0.6 on 2022-11-12 12:56
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('budget', '0006_remove_luxfixedmonthly_cat_and_more'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='luxpurchase',
+ name='cat',
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='budget.luxspendingcategory'),
+ ),
+ ]
diff --git a/app/budget/models.py b/app/budget/models.py
index 7afc4e2..7b7da75 100644
--- a/app/budget/models.py
+++ b/app/budget/models.py
@@ -14,20 +14,18 @@ class LuxSource(models.Model):
return self.name
+class LuxSpendingCategory(models.Model):
+ name = models.CharField(max_length=200)
+ date_recorded = models.DateTimeField(auto_now_add=True)
+
+ def __str__(self):
+ return self.name
+
+
class LuxFixedMonthly(models.Model):
name = models.CharField(max_length=200)
source = models.ForeignKey(LuxSource, on_delete=models.CASCADE)
- CATEGORY = (
- (0, 'Grocery & Home'),
- (1, 'Gas'),
- (2, 'Bus'),
- (3, 'Lodging'),
- (4, 'Books'),
- (5, 'Clothes'),
- (6, 'Eating Out'),
- (7, 'Misc'),
- )
- category = models.IntegerField(choices=CATEGORY, default=0)
+ category = models.ForeignKey(LuxSpendingCategory, on_delete=models.CASCADE)
date_recorded = models.DateTimeField(auto_now_add=True)
def __str__(self):
@@ -51,6 +49,7 @@ class LuxPurchaseStatsManager(models.Manager):
end_date = datetime.date(timezone.now().year, month, last_day)
return self.filter(date_recorded__range=(start_date, end_date)).filter(category=cat).aggregate(Sum('amount'))
+
class LuxPurchase(models.Model):
amount = models.DecimalField(max_digits=6, decimal_places=2)
source = models.ForeignKey(LuxSource, on_delete=models.CASCADE)
@@ -65,6 +64,7 @@ class LuxPurchase(models.Model):
(7, 'Misc'),
)
category = models.IntegerField(choices=CATEGORY, default=0)
+ cat = models.ForeignKey(LuxSpendingCategory, null=True, on_delete=models.CASCADE)
date_recorded = models.DateTimeField(auto_now_add=True)
class Meta: