mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-24 09:38:35 +02:00
feat: add option to archive accounts
This commit is contained in:
@@ -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",
|
||||
)
|
||||
|
||||
18
app/apps/accounts/migrations/0005_account_archived.py
Normal file
18
app/apps/accounts/migrations/0005_account_archived.py
Normal 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'),
|
||||
),
|
||||
]
|
||||
@@ -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'),
|
||||
),
|
||||
]
|
||||
@@ -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")
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user