feat: add option to archive accounts

This commit is contained in:
Herculino Trotta
2024-10-27 21:54:02 -03:00
parent 9f371c2693
commit bfd0cc45a3
8 changed files with 78 additions and 13 deletions

View File

@@ -60,7 +60,14 @@ class AccountForm(forms.ModelForm):
class Meta:
model = Account
fields = ["name", "group", "currency", "exchange_currency", "is_asset"]
fields = [
"name",
"group",
"currency",
"exchange_currency",
"is_asset",
"is_archived",
]
widgets = {
"currency": TomSelect(),
"exchange_currency": TomSelect(),
@@ -76,6 +83,7 @@ class AccountForm(forms.ModelForm):
"name",
"group",
Switch("is_asset"),
Switch("is_archived"),
"currency",
"exchange_currency",
)

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.1.2 on 2024-10-28 00:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0004_account_group'),
]
operations = [
migrations.AddField(
model_name='account',
name='archived',
field=models.BooleanField(default=False, help_text="Archived accounts don't show up nor count towards your net worth", verbose_name='Archived'),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.1.2 on 2024-10-28 00:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0005_account_archived'),
]
operations = [
migrations.RenameField(
model_name='account',
old_name='archived',
new_name='is_archived',
),
migrations.AlterField(
model_name='account',
name='is_asset',
field=models.BooleanField(default=False, help_text='Asset accounts count towards your Net Worth, but not towards your month.', verbose_name='Asset account'),
),
]

View File

@@ -43,11 +43,16 @@ class Account(models.Model):
is_asset = models.BooleanField(
default=False,
verbose_name=_("Is an asset account?"),
verbose_name=_("Asset account"),
help_text=_(
"Asset accounts count towards your Net Worth, but not towards your month."
),
)
is_archived = models.BooleanField(
default=False,
verbose_name=_("Archived"),
help_text=_("Archived accounts don't show up nor count towards your net worth"),
)
class Meta:
verbose_name = _("Account")

View File

@@ -38,7 +38,9 @@ def account_reconciliation(request):
"prefix": account.currency.prefix,
"current_balance": get_account_balance(account),
}
for account in Account.objects.all().select_related("currency", "group")
for account in Account.objects.filter(is_archived=False).select_related(
"currency", "group"
)
]
if request.method == "POST":