1
0
Fork 0

created if cases for changing of year for projects that were already there, but already have a project_of_year number

This commit is contained in:
alpcentaur 2023-12-27 15:48:11 +00:00
parent c113e37b3f
commit 7c05040d7b
1 changed files with 28 additions and 5 deletions

View File

@ -104,9 +104,20 @@ class Project(Volunteer):
'''we generate the autogenerated fields here''' '''we generate the autogenerated fields here'''
# we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors # we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
# but maybe there is a better solution? # 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() 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 # generation of field quartals
if self.end.month in [1, 2, 3]: if self.end.month in [1, 2, 3]:
@ -119,13 +130,25 @@ class Project(Volunteer):
self.end_quartal = 'Q4' self.end_quartal = 'Q4'
# generation of pid and financeID # 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)
# 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)
if not self.project_of_year:
#print('AAA')
# we need to determine if this is a new year with its first new project... # we need to determine if this is a new year with its first new project...
year = self.start.year year = self.start.year
#print(year) #print(year)
projects = Project.objects.filter(start__year=year) projects = Project.objects.filter(start__year=year)
print('projects after filter of startyear of project',projects)
if not projects: if not projects:
#print('BBB') #print('BBB')
self.project_of_year = 1 self.project_of_year = 1