Skip to content

Commit

Permalink
Add initial staff app
Browse files Browse the repository at this point in the history
  • Loading branch information
SamDudley committed Oct 8, 2024
1 parent 6810284 commit 1c80937
Show file tree
Hide file tree
Showing 18 changed files with 936 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
VCAP_SERVICES = env.json("VCAP_SERVICES", {})

INSTALLED_APPS = [
"staff.apps.StaffConfig",
"user",
"authbroker_client",
"future_years.apps.FutureYearsConfig",
Expand Down
1 change: 1 addition & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
path("data-lake/", include("data_lake.urls")),
path("oscar_return/", include("oscar_return.urls")),
path("upload_split_file/", include("upload_split_file.urls")),
path("staff/", include("staff.urls")),
path("admin/", admin.site.urls),
# TODO - split below out into develop only?
path(
Expand Down
13 changes: 12 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def future_year_dictionary(self):
)


class FinancialYearQuerySet(models.QuerySet):
def current(self):
return self.filter(current=True).first()

def future(self):
current_financial_year = self.current().financial_year
return self.filter(financial_year__gt=current_financial_year).order_by(
"-financial_year"
)


class FinancialYear(BaseModel):
"""Key and representation of the financial year"""

Expand All @@ -69,7 +80,7 @@ class FinancialYear(BaseModel):
current = models.BooleanField(default=False)
archived = models.BooleanField(default=False)
archived_at = models.DateTimeField(blank=True, null=True)
objects = models.Manager() # The default manager.
objects = FinancialYearQuerySet.as_manager()
financial_year_objects = FinancialYearManager()

def __str__(self):
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
web:
build:
Expand Down
7 changes: 6 additions & 1 deletion forecast/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def __str__(self):
return self.forecast_expenditure_type_name


class FinancialPeriodQuerySet(models.QuerySet):
def months(self):
return self.filter(financial_period_code__lte=12)


class FinancialPeriodManager(models.Manager):
def month_display_list(self):
return list(
Expand Down Expand Up @@ -296,7 +301,7 @@ class FinancialPeriod(BaseModel):
actual_loaded_previous_year = models.BooleanField(default=False)
display_figure = models.BooleanField(default=True)

objects = models.Manager() # The default manager.
objects = FinancialPeriodQuerySet.as_manager()
financial_period_info = FinancialPeriodManager()

class Meta:
Expand Down
Empty file added staff/__init__.py
Empty file.
61 changes: 61 additions & 0 deletions staff/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from django.contrib import admin

from staff.services.staff import staff_created

from .models import Staff, StaffForecast, Payroll, PayElement, PayElementGroup


@admin.register(Staff)
class StaffAdmin(admin.ModelAdmin):
list_display = [
"employee_no",
"first_name",
"last_name",
"cost_centre",
]

def save_model(self, request, obj, form, change):
super().save_model(request, obj, form, change)

if not change:
staff_created(obj)


@admin.register(StaffForecast)
class StaffForecastAdmin(admin.ModelAdmin):
list_display = [
"staff",
"year",
"period_1",
"period_2",
"period_3",
"period_4",
"period_5",
"period_6",
"period_7",
"period_8",
"period_9",
"period_10",
"period_11",
"period_12",
]


@admin.register(Payroll)
class PayrollAdmin(admin.ModelAdmin):
list_display = [
"staff",
"pay_element",
"debit_amount",
"credit_amount",
]


@admin.register(PayElement)
class PayElementAdmin(admin.ModelAdmin):
pass


@admin.register(PayElementGroup)
class PayElementGroupAdmin(admin.ModelAdmin):
pass
6 changes: 6 additions & 0 deletions staff/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class StaffConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "staff"
Loading

0 comments on commit 1c80937

Please sign in to comment.