Skip to content

Commit

Permalink
Refactor endpoint to include global attrition object
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitBarnard committed Feb 13, 2025
1 parent 655a63c commit 5c38cf9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions payroll/services/payroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,20 +403,25 @@ def get_pay_modifiers_data(
cost_centre: CostCentre,
financial_year: FinancialYear,
) -> Iterator[PayModifiers]:
attrition = get_attrition_instance(financial_year, cost_centre)
global_attrition = Attrition.objects.filter(
financial_year=financial_year, cost_centre=None
).first()
attrition = Attrition.objects.filter(
financial_year=financial_year, cost_centre=cost_centre
).first()
pay_uplift = PayUplift.objects.filter(
financial_year=financial_year,
).first()

attrition_periods = []
pay_uplift_periods = []

if attrition:
attrition_periods = attrition.periods
if pay_uplift:
pay_uplift_periods = pay_uplift.periods
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

return {"attrition": attrition_periods, "pay_uplift": pay_uplift_periods}
return {
"global_attrition": global_attrition_periods,
"attrition": attrition_periods,
"pay_uplift": pay_uplift_periods,
}


def create_default_pay_modifiers(
Expand Down

0 comments on commit 5c38cf9

Please sign in to comment.