diff --git a/core/models.py b/core/models.py index bc684a35..a46896ba 100644 --- a/core/models.py +++ b/core/models.py @@ -98,6 +98,10 @@ class Meta: def periods(self) -> list[float]: return [getattr(self, month) for month in MONTHS] + @property + def periods_as_percentage(self) -> list[float]: + return [month * 100 for month in self.periods] + financial_year = models.ForeignKey(FinancialYear, on_delete=models.PROTECT) apr = models.FloatField(default=1.0) may = models.FloatField(default=1.0) diff --git a/payroll/views.py b/payroll/views.py index 44c61d7f..42e3baf0 100644 --- a/payroll/views.py +++ b/payroll/views.py @@ -15,7 +15,7 @@ from .services import payroll as payroll_service -class PositionView(UserPassesTestMixin, View): +class EditPayrollView(UserPassesTestMixin, View): def test_func(self) -> bool | None: return self.request.user.is_superuser @@ -49,7 +49,7 @@ def post(self, request, *args, **kwargs): # TODO: check user has access to cost centre -class PayrollView(PositionView): +class PayrollView(EditPayrollView): def get_data(self): return payroll_service.get_payroll_data( self.cost_centre, @@ -64,7 +64,7 @@ def post_data(self, data): ) -class VacancyView(PositionView): +class VacancyView(EditPayrollView): def get_data(self): return payroll_service.get_vacancies_data( self.cost_centre, @@ -79,7 +79,7 @@ def post_data(self, data): ) -class PayModifierView(PositionView): +class PayModifierView(EditPayrollView): def get_data(self): return payroll_service.get_pay_modifiers_data( self.cost_centre,