Skip to content

Commit

Permalink
Revert "Merge branch 'main' into FFT-105/vacancy-pay-periods"
Browse files Browse the repository at this point in the history
This reverts commit 9861a40, reversing
changes made to 4b51dd5.
  • Loading branch information
CaitBarnard committed Nov 21, 2024
1 parent 6a50724 commit 2004e88
Show file tree
Hide file tree
Showing 27 changed files with 101 additions and 1,219 deletions.
64 changes: 9 additions & 55 deletions front_end/src/Apps/Payroll.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { useEffect, useReducer, useState, useMemo } from "react";
import { useEffect, useReducer, useState } from "react";

import EditPayroll from "../Components/EditPayroll";
import * as api from "../Components/EditPayroll/api";
import {
payrollHeaders,
vacancyHeaders,
} from "../Components/EditPayroll/constants";

const initialPayrollState = [];

export default function Payroll() {
const [allPayroll, dispatch] = useReducer(
payrollReducer,
initialPayrollState
);
const [payroll, dispatch] = useReducer(payrollReducer, initialPayrollState);
const [saveSuccess, setSaveSuccess] = useState(false);

useEffect(() => {
Expand All @@ -26,20 +19,10 @@ export default function Payroll() {
api.getPayrollData().then((data) => dispatch({ type: "fetched", data }));
}, []);

// Computed properties
const payroll = useMemo(
() => allPayroll.filter((payroll) => payroll.basic_pay > 0),
[allPayroll]
);
const nonPayroll = useMemo(
() => allPayroll.filter((payroll) => payroll.basic_pay <= 0),
[allPayroll]
);

// Handlers
async function handleSavePayroll() {
try {
await api.postPayrollData(allPayroll);
await api.postPayrollData(payroll);

setSaveSuccess(true);
localStorage.setItem("saveSuccess", "true");
Expand All @@ -55,41 +38,12 @@ export default function Payroll() {
}

return (
<>
{saveSuccess && (
<div className="govuk-notification-banner govuk-notification-banner--success">
<div className="govuk-notification-banner__header">
<h2
className="govuk-notification-banner__title"
id="govuk-notification-banner-title"
>
Success
</h2>
</div>
</div>
)}
<h2 className="govuk-heading-m">Payroll</h2>
<EditPayroll
payroll={payroll}
headers={payrollHeaders}
onTogglePayPeriods={handleTogglePayPeriods}
/>
<h2 className="govuk-heading-m">Non-payroll</h2>
<EditPayroll
payroll={nonPayroll}
headers={payrollHeaders}
onTogglePayPeriods={handleTogglePayPeriods}
/>
<h2 className="govuk-heading-m">Vacancies</h2>
<EditPayroll
payroll={[]}
headers={vacancyHeaders}
onTogglePayPeriods={handleTogglePayPeriods}
/>
<button className="govuk-button" onClick={handleSavePayroll}>
Save payroll
</button>
</>
<EditPayroll
payroll={payroll}
onSavePayroll={handleSavePayroll}
onTogglePayPeriods={handleTogglePayPeriods}
saveSuccess={saveSuccess}
/>
);
}

Expand Down
5 changes: 0 additions & 5 deletions front_end/src/Components/EditPayroll/EmployeeRow/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ const EmployeeRow = ({ row, onTogglePayPeriods }) => {
return (
<tr className="govuk-table__row">
<td className="govuk-table__cell">{row.name}</td>
<td className="govuk-table__cell">{row.grade}</td>
<td className="govuk-table__cell">{row.employee_no}</td>
<td className="govuk-table__cell">{row.fte}</td>
<td className="govuk-table__cell">{row.programme_code}</td>
<td className="govuk-table__cell">{row.budget_type}</td>
<td className="govuk-table__cell">{row.assignment_status}</td>
{row.pay_periods.map((enabled, index) => {
return (
<td className="govuk-table__cell" key={index}>
Expand Down
35 changes: 0 additions & 35 deletions front_end/src/Components/EditPayroll/constants.js

This file was deleted.

50 changes: 44 additions & 6 deletions front_end/src/Components/EditPayroll/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,50 @@ import PayrollTable from "./PayrollTable/index";
* @param {types.PayrollData[]} props.payroll
* @returns
*/
export default function EditPayroll({ payroll, headers, onTogglePayPeriods }) {
export default function EditPayroll({
payroll,
onSavePayroll,
onTogglePayPeriods,
saveSuccess,
}) {
const headers = [
"Name",
"Employee No",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"Jan",
"Feb",
"Mar",
];
return (
<PayrollTable
headers={headers}
payroll={payroll}
onTogglePayPeriods={onTogglePayPeriods}
></PayrollTable>
<>
{saveSuccess && (
<div className="govuk-notification-banner govuk-notification-banner--success">
<div className="govuk-notification-banner__header">
<h2
className="govuk-notification-banner__title"
id="govuk-notification-banner-title"
>
Success
</h2>
</div>
</div>
)}
<PayrollTable
headers={headers}
payroll={payroll}
onTogglePayPeriods={onTogglePayPeriods}
></PayrollTable>
<button className="govuk-button" onClick={onSavePayroll}>
Save payroll
</button>
</>
);
}
6 changes: 0 additions & 6 deletions front_end/src/Components/EditPayroll/types.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/**
* @typedef {Object} PayrollData
* @property {string} name - The employee's name.
* @property {string} grade - The employee's grade.
* @property {string} employee_no - The employee's number.
* @property {number} fte - The employee's FTE.
* @property {string} programme_code - The employee's programme code.
* @property {string} budget_type - The employee's programme code budget type.
* @property {string} assignment_status - The employee's assignment status.
* @property {string} basic_pay - The employee's basic pay.
* @property {boolean[]} pay_periods - Whether the employee is being paid in periods.
*/

Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ create-stub-data: # Create stub data for testing
$(web) $(manage) create_stub_forecast_data
$(web) $(manage) create_stub_future_forecast_data
$(web) $(manage) create_data_lake_stub_data
$(web) $(manage) populate_gift_hospitality_table
$(web) $(manage) loaddata test_payroll_data
$(web) $(manage) create_test_user --password=password

setup: # Set up the project from scratch
make down
make create-stub-data
make gift-hospitality-table
$(web) $(manage) create_test_user --password=password
$(web) $(manage) create_test_user [email protected] --group="Finance Administrator" --password=password # /PS-IGNORE
$(web) $(manage) create_test_user [email protected] --group="Finance Business Partner/BSCE" --password=password # /PS-IGNORE
Expand Down
21 changes: 1 addition & 20 deletions payroll/admin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from django.contrib import admin

from payroll.services.payroll import employee_created, vacancy_created
from payroll.services.payroll import employee_created

from .models import (
Employee,
EmployeePayElement,
EmployeePayPeriods,
PayElementType,
PayElementTypeGroup,
Vacancy,
)


Expand Down Expand Up @@ -76,21 +75,3 @@ class PayElementTypeGroupAdmin(admin.ModelAdmin):
"name",
"natural_code",
]


@admin.register(Vacancy)
class VacancyAdmin(admin.ModelAdmin):
list_display = [
"cost_centre",
"grade",
"programme_code",
"appointee_name",
"hiring_manager",
"hr_ref",
]

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

if not change:
vacancy_created(obj)
Loading

0 comments on commit 2004e88

Please sign in to comment.