From 7c05040d7bf3dedcfc0682cc359cb93fc2047828 Mon Sep 17 00:00:00 2001 From: alpcentaur Date: Wed, 27 Dec 2023 15:48:11 +0000 Subject: [PATCH] created if cases for changing of year for projects that were already there, but already have a project_of_year number --- input/models.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/input/models.py b/input/models.py index de4b8b5..1bc57ab 100755 --- a/input/models.py +++ b/input/models.py @@ -104,10 +104,21 @@ class Project(Volunteer): '''we generate the autogenerated fields here''' # we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors # but maybe there is a better solution? + startyear_tmp = 'NONE' + + if self.pid: + if self.pid[:4] != self.start.year: + startyear_tmp = self.start.year + super().save() - self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3) - # self.pid = str(self.account.code) + str(self.pk).zfill(3) - + + if startyear_tmp == 'NONE': + + self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3) + # self.pid = str(self.account.code) + str(self.pk).zfill(3) + + + # generation of field quartals if self.end.month in [1, 2, 3]: self.end_quartal = 'Q1' @@ -119,13 +130,25 @@ class Project(Volunteer): self.end_quartal = 'Q4' # generation of pid and financeID + # project of year is true if entry gets updated with changes.. but year can change!!!!!!!! + if self.project_of_year: + print('oi oi oi oi oi') + print(self.pid) - if not self.project_of_year: - #print('AAA') + + + + # project of year is false if entry gets saved as new + if not self.project_of_year or startyear_tmp != 'NONE': + print('AAA') + + print('self projekt of year', self.project_of_year, self.start.year) + # we need to determine if this is a new year with its first new project... year = self.start.year #print(year) projects = Project.objects.filter(start__year=year) + print('projects after filter of startyear of project',projects) if not projects: #print('BBB') self.project_of_year = 1