|
@ -104,10 +104,21 @@ 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]: |
|
|
self.end_quartal = 'Q1' |
|
|
self.end_quartal = 'Q1' |
|
@ -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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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... |
|
|
# 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 |
|
|