Browse Source

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

master
alpcentaur 11 months ago
parent
commit
7c05040d7b
1 changed files with 28 additions and 5 deletions
  1. +28
    -5
      input/models.py

+ 28
- 5
input/models.py View File

@ -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

Loading…
Cancel
Save