mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-24 09:38:35 +02:00
feat(transactions): add option for removing Recurring/Installment descriptions and notes from generated transactions
#209
This commit is contained in:
@@ -538,6 +538,8 @@ class InstallmentPlanForm(forms.ModelForm):
|
|||||||
"notes",
|
"notes",
|
||||||
"installment_start",
|
"installment_start",
|
||||||
"entities",
|
"entities",
|
||||||
|
"add_description_to_transaction",
|
||||||
|
"add_notes_to_transaction",
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
"account": TomSelect(),
|
"account": TomSelect(),
|
||||||
@@ -593,7 +595,9 @@ class InstallmentPlanForm(forms.ModelForm):
|
|||||||
css_class="form-row",
|
css_class="form-row",
|
||||||
),
|
),
|
||||||
"description",
|
"description",
|
||||||
|
Switch("add_description_to_transaction"),
|
||||||
"notes",
|
"notes",
|
||||||
|
Switch("add_notes_to_transaction"),
|
||||||
Row(
|
Row(
|
||||||
Column("number_of_installments", css_class="form-group col-md-6 mb-0"),
|
Column("number_of_installments", css_class="form-group col-md-6 mb-0"),
|
||||||
Column("installment_start", css_class="form-group col-md-6 mb-0"),
|
Column("installment_start", css_class="form-group col-md-6 mb-0"),
|
||||||
@@ -782,6 +786,7 @@ class RecurringTransactionForm(forms.ModelForm):
|
|||||||
"type",
|
"type",
|
||||||
"amount",
|
"amount",
|
||||||
"description",
|
"description",
|
||||||
|
"add_description_to_transaction",
|
||||||
"category",
|
"category",
|
||||||
"tags",
|
"tags",
|
||||||
"start_date",
|
"start_date",
|
||||||
@@ -790,6 +795,7 @@ class RecurringTransactionForm(forms.ModelForm):
|
|||||||
"recurrence_type",
|
"recurrence_type",
|
||||||
"recurrence_interval",
|
"recurrence_interval",
|
||||||
"notes",
|
"notes",
|
||||||
|
"add_notes_to_transaction",
|
||||||
"entities",
|
"entities",
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
@@ -850,6 +856,7 @@ class RecurringTransactionForm(forms.ModelForm):
|
|||||||
css_class="form-row",
|
css_class="form-row",
|
||||||
),
|
),
|
||||||
"description",
|
"description",
|
||||||
|
Switch("add_description_to_transaction"),
|
||||||
"amount",
|
"amount",
|
||||||
Row(
|
Row(
|
||||||
Column("category", css_class="form-group col-md-6 mb-0"),
|
Column("category", css_class="form-group col-md-6 mb-0"),
|
||||||
@@ -857,6 +864,7 @@ class RecurringTransactionForm(forms.ModelForm):
|
|||||||
css_class="form-row",
|
css_class="form-row",
|
||||||
),
|
),
|
||||||
"notes",
|
"notes",
|
||||||
|
Switch("add_notes_to_transaction"),
|
||||||
Row(
|
Row(
|
||||||
Column("start_date", css_class="form-group col-md-6 mb-0"),
|
Column("start_date", css_class="form-group col-md-6 mb-0"),
|
||||||
Column("reference_date", css_class="form-group col-md-6 mb-0"),
|
Column("reference_date", css_class="form-group col-md-6 mb-0"),
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-09 20:22
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('transactions', '0040_alter_transaction_unique_together_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='installmentplan',
|
||||||
|
name='add_description_to_transaction',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Add description to transactions'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='installmentplan',
|
||||||
|
name='add_notes_to_transaction',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Add notes to transactions'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='recurringtransaction',
|
||||||
|
name='add_description_to_transaction',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Add description to transactions'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='recurringtransaction',
|
||||||
|
name='add_notes_to_transaction',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Add notes to transactions'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -493,6 +493,13 @@ class InstallmentPlan(models.Model):
|
|||||||
|
|
||||||
notes = models.TextField(blank=True, verbose_name=_("Notes"))
|
notes = models.TextField(blank=True, verbose_name=_("Notes"))
|
||||||
|
|
||||||
|
add_description_to_transaction = models.BooleanField(
|
||||||
|
default=True, verbose_name=_("Add description to transactions")
|
||||||
|
)
|
||||||
|
add_notes_to_transaction = models.BooleanField(
|
||||||
|
default=True, verbose_name=_("Add notes to transactions")
|
||||||
|
)
|
||||||
|
|
||||||
all_objects = models.Manager() # Unfiltered manager
|
all_objects = models.Manager() # Unfiltered manager
|
||||||
objects = GenericAccountOwnerManager() # Default filtered manager
|
objects = GenericAccountOwnerManager() # Default filtered manager
|
||||||
|
|
||||||
@@ -557,11 +564,13 @@ class InstallmentPlan(models.Model):
|
|||||||
is_paid=False,
|
is_paid=False,
|
||||||
reference_date=transaction_reference_date,
|
reference_date=transaction_reference_date,
|
||||||
amount=self.installment_amount,
|
amount=self.installment_amount,
|
||||||
description=self.description,
|
description=(
|
||||||
|
self.description if self.add_description_to_transaction else ""
|
||||||
|
),
|
||||||
category=self.category,
|
category=self.category,
|
||||||
installment_plan=self,
|
installment_plan=self,
|
||||||
installment_id=i,
|
installment_id=i,
|
||||||
notes=self.notes,
|
notes=self.notes if self.add_notes_to_transaction else "",
|
||||||
)
|
)
|
||||||
new_transaction.tags.set(self.tags.all())
|
new_transaction.tags.set(self.tags.all())
|
||||||
new_transaction.entities.set(self.entities.all())
|
new_transaction.entities.set(self.entities.all())
|
||||||
@@ -594,9 +603,13 @@ class InstallmentPlan(models.Model):
|
|||||||
existing_transaction.type = self.type
|
existing_transaction.type = self.type
|
||||||
existing_transaction.date = transaction_date
|
existing_transaction.date = transaction_date
|
||||||
existing_transaction.reference_date = transaction_reference_date
|
existing_transaction.reference_date = transaction_reference_date
|
||||||
existing_transaction.description = self.description
|
existing_transaction.description = (
|
||||||
|
self.description if self.add_description_to_transaction else ""
|
||||||
|
)
|
||||||
existing_transaction.category = self.category
|
existing_transaction.category = self.category
|
||||||
existing_transaction.notes = self.notes
|
existing_transaction.notes = (
|
||||||
|
self.notes if self.add_notes_to_transaction else ""
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not existing_transaction.is_paid
|
not existing_transaction.is_paid
|
||||||
@@ -617,11 +630,13 @@ class InstallmentPlan(models.Model):
|
|||||||
is_paid=False,
|
is_paid=False,
|
||||||
reference_date=transaction_reference_date,
|
reference_date=transaction_reference_date,
|
||||||
amount=self.installment_amount,
|
amount=self.installment_amount,
|
||||||
description=self.description,
|
description=(
|
||||||
|
self.description if self.add_description_to_transaction else ""
|
||||||
|
),
|
||||||
category=self.category,
|
category=self.category,
|
||||||
installment_plan=self,
|
installment_plan=self,
|
||||||
installment_id=i,
|
installment_id=i,
|
||||||
notes=self.notes,
|
notes=self.notes if self.add_notes_to_transaction else "",
|
||||||
)
|
)
|
||||||
new_transaction.tags.set(self.tags.all())
|
new_transaction.tags.set(self.tags.all())
|
||||||
new_transaction.entities.set(self.entities.all())
|
new_transaction.entities.set(self.entities.all())
|
||||||
@@ -697,6 +712,13 @@ class RecurringTransaction(models.Model):
|
|||||||
verbose_name=_("Last Generated Reference Date"), null=True, blank=True
|
verbose_name=_("Last Generated Reference Date"), null=True, blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_description_to_transaction = models.BooleanField(
|
||||||
|
default=True, verbose_name=_("Add description to transactions")
|
||||||
|
)
|
||||||
|
add_notes_to_transaction = models.BooleanField(
|
||||||
|
default=True, verbose_name=_("Add notes to transactions")
|
||||||
|
)
|
||||||
|
|
||||||
all_objects = models.Manager() # Unfiltered manager
|
all_objects = models.Manager() # Unfiltered manager
|
||||||
objects = GenericAccountOwnerManager() # Default filtered manager
|
objects = GenericAccountOwnerManager() # Default filtered manager
|
||||||
|
|
||||||
@@ -743,11 +765,13 @@ class RecurringTransaction(models.Model):
|
|||||||
date=date,
|
date=date,
|
||||||
reference_date=reference_date.replace(day=1),
|
reference_date=reference_date.replace(day=1),
|
||||||
amount=self.amount,
|
amount=self.amount,
|
||||||
description=self.description,
|
description=(
|
||||||
|
self.description if self.add_description_to_transaction else ""
|
||||||
|
),
|
||||||
category=self.category,
|
category=self.category,
|
||||||
is_paid=False,
|
is_paid=False,
|
||||||
recurring_transaction=self,
|
recurring_transaction=self,
|
||||||
notes=self.notes,
|
notes=self.notes if self.add_notes_to_transaction else "",
|
||||||
)
|
)
|
||||||
if self.tags.exists():
|
if self.tags.exists():
|
||||||
created_transaction.tags.set(self.tags.all())
|
created_transaction.tags.set(self.tags.all())
|
||||||
@@ -821,9 +845,13 @@ class RecurringTransaction(models.Model):
|
|||||||
for existing_transaction in unpaid_transactions:
|
for existing_transaction in unpaid_transactions:
|
||||||
# Update fields based on RecurringTransaction
|
# Update fields based on RecurringTransaction
|
||||||
existing_transaction.amount = self.amount
|
existing_transaction.amount = self.amount
|
||||||
existing_transaction.description = self.description
|
existing_transaction.description = (
|
||||||
|
self.description if self.add_description_to_transaction else ""
|
||||||
|
)
|
||||||
existing_transaction.category = self.category
|
existing_transaction.category = self.category
|
||||||
existing_transaction.notes = self.notes
|
existing_transaction.notes = (
|
||||||
|
self.notes if self.add_notes_to_transaction else ""
|
||||||
|
)
|
||||||
|
|
||||||
# Update many-to-many relationships
|
# Update many-to-many relationships
|
||||||
existing_transaction.tags.set(self.tags.all())
|
existing_transaction.tags.set(self.tags.all())
|
||||||
|
|||||||
Reference in New Issue
Block a user