From 49f28834e95c54c4eccde9656de66581ccdb08d6 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Wed, 26 Nov 2025 16:39:51 -0300 Subject: [PATCH] fix: unable to create transactions with an empty reference date when importing fixes #410 --- app/apps/transactions/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/apps/transactions/models.py b/app/apps/transactions/models.py index 12a65cf..a1dbc50 100644 --- a/app/apps/transactions/models.py +++ b/app/apps/transactions/models.py @@ -408,6 +408,10 @@ class Transaction(OwnedObject): self.reference_date = self.date.replace(day=1) def save(self, *args, **kwargs): + # This is here so Django validation doesn't trigger an error before clean() is ran + if not self.reference_date and self.date: + self.reference_date = self.date.replace(day=1) + # This is not recommended as it will run twice on some cases like form and API saves. # We only do this here because we forgot to independently call it on multiple places. self.full_clean()