From 7c6018d77d1f68ea6567f5832e8a992ea94cf706 Mon Sep 17 00:00:00 2001 From: Caitlin Barnard Date: Tue, 4 Feb 2025 11:36:53 +0000 Subject: [PATCH 01/16] Basic display functionality for pay uplift --- front_end/src/Apps/Payroll.jsx | 18 +++++++++- .../EditPayroll/DisplayPayModifier/index.jsx | 34 +++++++++++++++++++ .../EditPayroll/EditPayModifier/index.jsx | 17 +++------- .../EditPayroll/PayModifierHeaders/index.jsx | 19 +++++++++++ payroll/services/payroll.py | 25 +++++++++++--- 5 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx create mode 100644 front_end/src/Components/EditPayroll/PayModifierHeaders/index.jsx diff --git a/front_end/src/Apps/Payroll.jsx b/front_end/src/Apps/Payroll.jsx index 0d9ab940d..1837238f5 100644 --- a/front_end/src/Apps/Payroll.jsx +++ b/front_end/src/Apps/Payroll.jsx @@ -10,6 +10,7 @@ import VacancyRow from "../Components/EditPayroll/VacancyRow"; import PayrollTable from "../Components/EditPayroll/PayrollTable"; import Tabs, { Tab } from "../Components/EditPayroll/Tabs"; import EditPayModifier from "../Components/EditPayroll/EditPayModifier"; +import DisplayPayModifier from "../Components/EditPayroll/DisplayPayModifier"; import ToggleCheckbox from "../Components/Common/ToggleCheckbox"; import ErrorSummary from "../Components/Common/ErrorSummary"; import SuccessBanner from "../Components/Common/SuccessBanner"; @@ -72,6 +73,20 @@ export default function Payroll() { () => allPayroll.employees.filter((payroll) => payroll.basic_pay <= 0), [allPayroll], ); + const attrition = useMemo( + () => + allPayroll.pay_modifiers.filter( + (modifier) => modifier.name == "Attrition", + ), + [allPayroll], + ); + const pay_uplift = useMemo( + () => + allPayroll.pay_modifiers.filter( + (modifier) => modifier.name == "Pay Uplift", + ), + [allPayroll], + ); const forecastAndActuals = useMemo(() => { const total_results = []; @@ -195,10 +210,11 @@ export default function Payroll() { + + )} ); } return ( -
-

Pay Uplift

+ <> +

{title}

@@ -27,7 +40,21 @@ const DisplayPayModifier = ({ data }) => {
-
+ {isAttrition && ( + <> +

+ This attrition is for the current financial year. You can add one + for this specific cost centre instead. +

+ + + )} + ); }; From 9d0693020c911c43c95ccd5889356c846263b675 Mon Sep 17 00:00:00 2001 From: Caitlin Barnard Date: Thu, 13 Feb 2025 15:35:25 +0000 Subject: [PATCH 13/16] Refactor editModifier to be specific to displaying attrition --- front_end/src/Apps/Payroll.jsx | 23 ++---- .../EditPayroll/DisplayAttrition/index.jsx | 71 +++++++++++++++++++ .../EditPayroll/DisplayPayModifier/index.jsx | 29 +------- .../EditPayroll/EditPayModifier/index.jsx | 47 ------------ 4 files changed, 79 insertions(+), 91 deletions(-) create mode 100644 front_end/src/Components/EditPayroll/DisplayAttrition/index.jsx delete mode 100644 front_end/src/Components/EditPayroll/EditPayModifier/index.jsx diff --git a/front_end/src/Apps/Payroll.jsx b/front_end/src/Apps/Payroll.jsx index e36a52bcc..dec7f878c 100644 --- a/front_end/src/Apps/Payroll.jsx +++ b/front_end/src/Apps/Payroll.jsx @@ -9,7 +9,7 @@ import EmployeeRow from "../Components/EditPayroll/EmployeeRow"; import VacancyRow from "../Components/EditPayroll/VacancyRow"; import PayrollTable from "../Components/EditPayroll/PayrollTable"; import Tabs, { Tab } from "../Components/EditPayroll/Tabs"; -import EditPayModifier from "../Components/EditPayroll/EditPayModifier"; +import DisplayAttrition from "../Components/EditPayroll/DisplayAttrition"; import DisplayPayModifier from "../Components/EditPayroll/DisplayPayModifier"; import ToggleCheckbox from "../Components/Common/ToggleCheckbox"; import ErrorSummary from "../Components/Common/ErrorSummary"; @@ -194,21 +194,12 @@ export default function Payroll() { - {allPayroll.pay_modifiers.attrition && - allPayroll.pay_modifiers.attrition.length ? ( - - ) : ( - - )} + { + if (attrition && attrition.length > 0) { + return ( +
+

Attrition

+ + + + + {attrition.map((value, index) => { + return ( + + ); + })} + + +
+ onInputChange(index, e.target.value)} + > +
+
+ ); + } + + if (global_attrition && global_attrition.length > 0) { + return ( + <> + +

+ This attrition is for the current financial year. You can add one for + this specific cost centre instead. +

+ + + ); + } + + return ( + <> +

Attrition

+

No attrition set

+ + + ); +}; + +export default DisplayAttrition; diff --git a/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx b/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx index 56c304161..f4af0caac 100644 --- a/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx +++ b/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx @@ -1,24 +1,11 @@ import PayModifierHeaders from "../PayModifierHeaders"; -const DisplayPayModifier = ({ - data, - title, - isAttrition = false, - onCreate = [], -}) => { +const DisplayPayModifier = ({ data, title }) => { if (!data || data <= 0) { return ( <>

{title}

No {title.toLowerCase()} set

- {isAttrition && ( - - )} ); } @@ -40,20 +27,6 @@ const DisplayPayModifier = ({ - {isAttrition && ( - <> -

- This attrition is for the current financial year. You can add one - for this specific cost centre instead. -

- - - )} ); }; diff --git a/front_end/src/Components/EditPayroll/EditPayModifier/index.jsx b/front_end/src/Components/EditPayroll/EditPayModifier/index.jsx deleted file mode 100644 index 06ca5f543..000000000 --- a/front_end/src/Components/EditPayroll/EditPayModifier/index.jsx +++ /dev/null @@ -1,47 +0,0 @@ -import PayModifierHeaders from "../PayModifierHeaders"; - -const EditPayModifier = ({ data, onInputChange, onCreate }) => { - if (!data || data <= 0) { - return ( - <> -

Attrition

-

No attrition set

- - - ); - } - - return ( -
-

Attrition

- - - - - {data.map((value, index) => { - return ( - - ); - })} - - -
- onInputChange(index, e.target.value)} - > -
-
- ); -}; - -export default EditPayModifier; From fbab379a1f15f578af01f3804ac9cef6ac5f73b0 Mon Sep 17 00:00:00 2001 From: Caitlin Barnard Date: Thu, 13 Feb 2025 15:43:25 +0000 Subject: [PATCH 14/16] Update types --- front_end/src/Components/EditPayroll/types.js | 5 +++-- payroll/services/payroll.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/front_end/src/Components/EditPayroll/types.js b/front_end/src/Components/EditPayroll/types.js index a701e4a84..063398c6a 100644 --- a/front_end/src/Components/EditPayroll/types.js +++ b/front_end/src/Components/EditPayroll/types.js @@ -27,7 +27,8 @@ /** * @typedef {Object} PayModifierData - * @property {float[]} attrition - The monthly percentages for attrition + * @property {float[]} global_attrition - The monthly percentages for attrition for that financial year + * @property {float[]} attrition - The monthly percentages for attrition scoped to the cost centre * @property {float[]} pay_uplift - The monthly percentages for pay uplift */ @@ -60,7 +61,7 @@ * @typedef {Object} PayrollData * @property {EmployeeData[]} employees - A list of employees * @property {VacancyData[]} vacancies - A list of vacancies - * @property {PayModifierData[]} pay_modifiers - An object with attrition and pay uplift + * @property {PayModifierData[]} pay_modifiers - An object with attrition, global attrition and pay uplift * @property {ForecastData[]} forecast - A list of forecast data * @property {PreviousMonthsData[]} previous_months - A list of months with actuals loaded */ diff --git a/payroll/services/payroll.py b/payroll/services/payroll.py index 359d31e25..ad3cfe4be 100644 --- a/payroll/services/payroll.py +++ b/payroll/services/payroll.py @@ -395,6 +395,7 @@ def update_vacancies_data( class PayModifiers(TypedDict): + global_attrition: list[float] attrition: list[float] pay_uplift: list[float] From 754a6bd35ebb83fa3d8edd56670f06f3cc0e62ac Mon Sep 17 00:00:00 2001 From: Caitlin Barnard Date: Thu, 13 Feb 2025 16:14:20 +0000 Subject: [PATCH 15/16] Flip logic of pay modifiers in service method --- payroll/services/payroll.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/payroll/services/payroll.py b/payroll/services/payroll.py index ad3cfe4be..4e8e56c33 100644 --- a/payroll/services/payroll.py +++ b/payroll/services/payroll.py @@ -414,9 +414,9 @@ def get_pay_modifiers_data( financial_year=financial_year, ).first() - global_attrition_periods = [] if not global_attrition else global_attrition.periods - attrition_periods = [] if not attrition else attrition.periods - pay_uplift_periods = [] if not pay_uplift else pay_uplift.periods + global_attrition_periods = global_attrition.periods if global_attrition else [] + attrition_periods = attrition.periods if attrition else [] + pay_uplift_periods = pay_uplift.periods if pay_uplift else [] return { "global_attrition": global_attrition_periods, From c8af9cc4bd43ae1861d74fc948e94d593785411e Mon Sep 17 00:00:00 2001 From: Caitlin Barnard Date: Fri, 14 Feb 2025 09:56:31 +0000 Subject: [PATCH 16/16] Refactor --- front_end/src/Apps/Payroll.jsx | 2 +- .../EditPayroll/DisplayAttrition/index.jsx | 13 ++++++++----- .../EditPayroll/DisplayPayModifier/index.jsx | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/front_end/src/Apps/Payroll.jsx b/front_end/src/Apps/Payroll.jsx index dec7f878c..471ecb148 100644 --- a/front_end/src/Apps/Payroll.jsx +++ b/front_end/src/Apps/Payroll.jsx @@ -201,7 +201,7 @@ export default function Payroll() { onCreate={handleCreateAttrition} />
diff --git a/front_end/src/Components/EditPayroll/DisplayAttrition/index.jsx b/front_end/src/Components/EditPayroll/DisplayAttrition/index.jsx index 7e5c8f01a..9b8a3723c 100644 --- a/front_end/src/Components/EditPayroll/DisplayAttrition/index.jsx +++ b/front_end/src/Components/EditPayroll/DisplayAttrition/index.jsx @@ -2,12 +2,12 @@ import PayModifierHeaders from "../PayModifierHeaders"; import DisplayPayModifier from "../DisplayPayModifier"; const DisplayAttrition = ({ - attrition, - global_attrition, + attrition = [], + global_attrition = [], onInputChange, onCreate, }) => { - if (attrition && attrition.length > 0) { + if (attrition.length > 0) { return (

Attrition

@@ -36,10 +36,13 @@ const DisplayAttrition = ({ ); } - if (global_attrition && global_attrition.length > 0) { + if (global_attrition.length > 0) { return ( <> - +

This attrition is for the current financial year. You can add one for this specific cost centre instead. diff --git a/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx b/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx index f4af0caac..fe6e297e3 100644 --- a/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx +++ b/front_end/src/Components/EditPayroll/DisplayPayModifier/index.jsx @@ -1,7 +1,7 @@ import PayModifierHeaders from "../PayModifierHeaders"; -const DisplayPayModifier = ({ data, title }) => { - if (!data || data <= 0) { +const DisplayPayModifier = ({ modifier = [], title }) => { + if (modifier.length === 0) { return ( <>

{title}

@@ -17,7 +17,7 @@ const DisplayPayModifier = ({ data, title }) => { - {data.map((value, index) => { + {modifier.map((value, index) => { return ( {value}