RSE-Sheffield / RSEAdmin

A Resource Allocation and Finance tool for RSE Groups
https://rseadmin.readthedocs.io/en/latest/
MIT License
24 stars 6 forks source link

500 error for project if auto-increments not set up for salary band #182

Open alisonrclarke opened 2 years ago

alisonrclarke commented 2 years ago

We've just set up an instance of RSEAdmin to trial at ARC in Durham.

I created a salary band that had auto-increments set but had not added salary details fo the next financial year. I added a project with 40% FTE at that salary band, with an end date in 2023. Going to the project page (/project/1) gave a 500 error.

The logs gave:

2022-02-09 10:24:15,922: Internal Server Error: /project/1
Traceback (most recent call last):
  File "/home/durhamarc/.virtualenvs/rseadmin-virtualenv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/durhamarc/.virtualenvs/rseadmin-virtualenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/durhamarc/.virtualenvs/rseadmin-virtualenv/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "./rse/views/projects.py", line 72, in project
    append_project_and_allocation_costs(request, proj, allocations)
  File "./rse/views/helper.py", line 32, in append_project_and_allocation_costs
    total_value = project.value()
  File "./rse/models.py", line 911, in value
    salary_costs = self.salary_band.staff_cost(self.start, self.end, percentage=self.percentage)
  File "./rse/models.py", line 256, in staff_cost
    next_sb = next_sb.salary_band_after_increment()
  File "./rse/models.py", line 134, in salary_band_after_increment
    raise ObjectDoesNotExist('Incomplete salary data in database. Could not find a valid increment for current salary band.')
django.core.exceptions.ObjectDoesNotExist: Incomplete salary data in database. Could not find a valid increment for current salary band.

I removed auto-increments from the salary band for now, which fixed the issue, but thought it was worth flagging.

(If I ever have time to set up a dev instance I'll see if I can fix the 500 page!)

MarkUoLeeds commented 2 years ago

I am just starting to try this and got a similar error and now I cannot even delete the project that fails. I can prob ignore it though:

Environment:

Request Method: GET Request URL: http://127.0.0.1:8080/project/3

Django Version: 3.2.11 Python Version: 3.10.5 Installed Applications: ['polymorphic', 'rse.apps.RseConfig', 'timetracking.apps.TimetrackingConfig', 'django_adminlte', 'django_adminlte_theme', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last): File "C:\Users\earmgr\AppData\Local\pypoetry\Cache\virtualenvs\rseadmin-AQgX_F6I-py3.10\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\earmgr\AppData\Local\pypoetry\Cache\virtualenvs\rseadmin-AQgX_F6I-py3.10\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, *callback_kwargs) File "C:\Users\earmgr\AppData\Local\pypoetry\Cache\virtualenvs\rseadmin-AQgX_F6I-py3.10\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view return view_func(request, args, **kwargs) File "C:\Users\earmgr\Documents\Python Scripts\RSEAdminTool\rseadmin_git\rse\views\projects.py", line 72, in project append_project_and_allocation_costs(request, proj, allocations) File "C:\Users\earmgr\Documents\Python Scripts\RSEAdminTool\rseadmin_git\rse\views\helper.py", line 32, in append_project_and_allocation_costs total_value = project.value() File "C:\Users\earmgr\Documents\Python Scripts\RSEAdminTool\rseadmin_git\rse\models.py", line 911, in value salary_costs = self.salary_band.staff_cost(self.start, self.end, percentage=self.percentage) File "C:\Users\earmgr\Documents\Python Scripts\RSEAdminTool\rseadmin_git\rse\models.py", line 256, in staff_cost next_sb = next_sb.salary_band_after_increment() File "C:\Users\earmgr\Documents\Python Scripts\RSEAdminTool\rseadmin_git\rse\models.py", line 134, in salary_band_after_increment raise ObjectDoesNotExist('Incomplete salary data in database. Could not find a valid increment for current salary band.')

Exception Type: ObjectDoesNotExist at /project/3 Exception Value: Incomplete salary data in database. Could not find a valid increment for current salary band.