Skip to content

Commit 0fd0d00

Browse files
committed
Refactor part time fees to be amount rather then percent
1 parent 08daaef commit 0fd0d00

6 files changed

Lines changed: 26 additions & 28 deletions

File tree

src/components/HrTools/PdsGoalCalculator/SupportItem/otherBreakdown.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const constants: OtherExpensesConstants = {
2020
salarySubtotal: 5000,
2121
fourOThreeBPercentage: 0.08,
2222
grossMonthlyPay: 5000,
23-
workCompPercentage: 0.02,
23+
workCompAmount: 100,
2424
attritionRate: 0.05,
2525
creditCardFeeRate: 0.03,
2626
adminRate: 0.1,

src/components/HrTools/PdsGoalCalculator/calculations/OtherExpenses.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const defaultConstants: OtherExpensesConstants = {
1010
salarySubtotal: 5000,
1111
fourOThreeBPercentage: 0.1,
1212
grossMonthlyPay: 4000,
13-
workCompPercentage: 0.17,
13+
workCompAmount: 680,
1414
attritionRate: 0.06,
1515
creditCardFeeRate: 0.06,
1616
adminRate: 0.12,
@@ -57,9 +57,9 @@ describe('calculateOtherExpenses', () => {
5757
});
5858

5959
describe('work comp', () => {
60-
it('calculates as grossMonthlyPay × workCompPercentage for part-time', () => {
60+
it('uses the fixed workCompAmount for part-time', () => {
6161
const result = calculateOtherExpenses(partTime(), defaultConstants);
62-
// 4000 * 0.17
62+
// fixed amount
6363
expect(result.workComp).toBeCloseTo(680);
6464
});
6565

@@ -183,7 +183,7 @@ describe('calculateOtherExpenses', () => {
183183

184184
it('produces correct totals for a part-time employee', () => {
185185
const result = calculateOtherExpenses(partTime(), defaultConstants);
186-
// reimbursable=500, 403b=400, workComp=4000*0.17=680, benefits=0
186+
// reimbursable=500, 403b=400, workComp=680 (fixed), benefits=0
187187
// subtotal=5000+500+400+680+0=6580
188188
// attrition=6580*0.06=394.80
189189
// creditCardFees=(6580+394.80)/(1-0.06)-(6580+394.80)≈445.20

src/components/HrTools/PdsGoalCalculator/calculations/OtherExpenses.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface OtherExpensesConstants {
1414
salarySubtotal: number;
1515
fourOThreeBPercentage: number;
1616
grossMonthlyPay: number;
17-
workCompPercentage: number;
17+
workCompAmount: number;
1818
attritionRate: number;
1919
creditCardFeeRate: number;
2020
adminRate: number;
@@ -41,9 +41,7 @@ export const calculateOtherExpenses = (
4141
const reimbursableExpenses = constants.reimbursableTotal;
4242
const fourOThreeBContributions =
4343
constants.grossMonthlyPay * constants.fourOThreeBPercentage;
44-
const workComp = isPartTime
45-
? constants.grossMonthlyPay * constants.workCompPercentage
46-
: 0;
44+
const workComp = isPartTime ? constants.workCompAmount : 0;
4745
const benefits = isFullTime ? (calculation.benefits ?? 0) : 0;
4846

4947
const subtotal =

src/components/HrTools/PdsGoalCalculator/calculations/buildPdsGoalConstants.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const buildMiscConstants = (
2828
: { EMPLOYER_FICA_RATE: makeConstant(0.08) }),
2929
...(overrides.workComp !== undefined
3030
? { PART_TIME_WORK_COMPENSATION: makeConstant(overrides.workComp) }
31-
: { PART_TIME_WORK_COMPENSATION: makeConstant(0.17) }),
31+
: { PART_TIME_WORK_COMPENSATION: makeConstant(20.35) }),
3232
...(overrides.creditCardFeeRate !== undefined
3333
? { CREDIT_CARD_FEE_RATE: makeConstant(overrides.creditCardFeeRate) }
3434
: { CREDIT_CARD_FEE_RATE: makeConstant(0.06) }),
@@ -59,7 +59,7 @@ describe('buildPdsGoalConstants', () => {
5959

6060
expect(result).toEqual({
6161
employerFicaRate: 0.08,
62-
workCompPercentage: 0.17,
62+
workCompAmount: 20.35,
6363
attritionRate: 0.06,
6464
creditCardFeeRate: 0.06,
6565
adminRate: 0.12,

src/components/HrTools/PdsGoalCalculator/calculations/pdsGoalConstants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { SalaryTotals } from './salaryCalculation';
99

1010
export interface PdsGoalTotalConstants {
1111
employerFicaRate: number;
12-
workCompPercentage: number;
12+
workCompAmount: number;
1313
attritionRate: number;
1414
creditCardFeeRate: number;
1515
adminRate: number;
@@ -29,14 +29,14 @@ export const buildPdsGoalConstants = (
2929
const rates = goalMiscConstants.RATES;
3030

3131
const employerFicaRate = additionalRates?.EMPLOYER_FICA_RATE?.fee;
32-
const workCompPercentage = additionalRates?.PART_TIME_WORK_COMPENSATION?.fee;
32+
const workCompAmount = additionalRates?.PART_TIME_WORK_COMPENSATION?.fee;
3333
const attritionRate = rates?.ATTRITION_RATE?.fee;
3434
const creditCardFeeRate = additionalRates?.CREDIT_CARD_FEE_RATE?.fee;
3535
const adminRate = rates?.ADMIN_RATE?.fee;
3636

3737
if (
3838
employerFicaRate === undefined ||
39-
workCompPercentage === undefined ||
39+
workCompAmount === undefined ||
4040
attritionRate === undefined ||
4141
creditCardFeeRate === undefined ||
4242
adminRate === undefined
@@ -52,7 +52,7 @@ export const buildPdsGoalConstants = (
5252

5353
return {
5454
employerFicaRate,
55-
workCompPercentage,
55+
workCompAmount,
5656
attritionRate,
5757
creditCardFeeRate,
5858
adminRate,
@@ -73,7 +73,7 @@ export const buildOtherExpensesConstants = (
7373
salarySubtotal: salaryTotals.subtotal,
7474
fourOThreeBPercentage: isSimple ? 0 : constants.fourOThreeBPercentage,
7575
grossMonthlyPay: salaryTotals.grossMonthlyPay,
76-
workCompPercentage: constants.workCompPercentage,
76+
workCompAmount: constants.workCompAmount,
7777
attritionRate: constants.attritionRate,
7878
creditCardFeeRate: constants.creditCardFeeRate,
7979
adminRate: constants.adminRate,

src/components/HrTools/PdsGoalCalculator/calculations/usePdsSummaryData.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const mockUseGoalCalculatorConstants =
3131
>;
3232

3333
const EMPLOYER_FICA_RATE = 0.08;
34-
const WORK_COMP_PERCENTAGE = 0.17;
34+
const WORK_COMP_AMOUNT = 400;
3535
const ATTRITION_RATE = 0.06;
3636
const CREDIT_CARD_FEE_RATE = 0.06;
3737
const ADMIN_RATE = 0.12;
@@ -51,7 +51,7 @@ const constantsMock = gqlMock<GoalCalculatorConstantsQuery>(
5151
{
5252
category: MpdGoalMiscConstantCategoryEnum.AdditionalRates,
5353
label: MpdGoalMiscConstantLabelEnum.PartTimeWorkCompensation,
54-
fee: WORK_COMP_PERCENTAGE,
54+
fee: WORK_COMP_AMOUNT,
5555
},
5656
{
5757
category: MpdGoalMiscConstantCategoryEnum.AdditionalRates,
@@ -151,7 +151,7 @@ describe('usePdsSummaryData', () => {
151151
},
152152
],
153153
[
154-
'workCompPercentage',
154+
'workCompAmount',
155155
{
156156
ADDITIONAL_RATES: {
157157
...defaultConstants.goalMiscConstants.ADDITIONAL_RATES,
@@ -329,14 +329,14 @@ describe('usePdsSummaryData', () => {
329329
// Reimbursable: monthly = 400, annual = 1200, raw = 500, above floor
330330
//
331331
// 403b = 2166.667 * 0.08 = 173.333
332-
// workComp = 2166.667 * 0.17 = 368.333 (part-time)
332+
// workComp = 400 (fixed amount, part-time)
333333
// benefits = 0 (part-time, ignores calculation.benefits)
334-
// subtotal = 2340 + 500 + 173.333 + 368.333 + 0 = 3381.667
335-
// attrition = 3381.667 * 0.06 = 202.9
336-
// creditCardFees = (3381.667 + 202.9) / (1 - 0.06) - (3381.667 + 202.9) ≈ 228.80
337-
// adminBase ≈ 3813.37
338-
// assessment = adminBase / (1 - 0.12) - adminBase ≈ 520.00
339-
// overallTotal ≈ 3381.667 + 202.9 + 228.80 + 520.004333.37
334+
// subtotal = 2340 + 500 + 173.333 + 400 + 0 = 3413.333
335+
// attrition = 3413.333 * 0.06 = 204.8
336+
// creditCardFees = (3413.333 + 204.8) / (1 - 0.06) - (3413.333 + 204.8) ≈ 230.94
337+
// adminBase ≈ 3849.08
338+
// assessment = adminBase / (1 - 0.12) - adminBase ≈ 524.87
339+
// overallTotal ≈ 3413.333 + 204.8 + 230.94 + 524.874373.95
340340
const calc = {
341341
...defaultCalculation,
342342
salaryOrHourly: DesignationSupportSalaryType.Hourly,
@@ -348,8 +348,8 @@ describe('usePdsSummaryData', () => {
348348
const { result } = renderHook(() =>
349349
usePdsSummaryData(calc, defaultHcmUser),
350350
);
351-
expect(result.current.data?.overallTotal).toBeCloseTo(4333.37, 0);
352-
expect(result.current.data?.otherTotals.workComp).toBeCloseTo(368.33, 2);
351+
expect(result.current.data?.overallTotal).toBeCloseTo(4373.95, 0);
352+
expect(result.current.data?.otherTotals.workComp).toBeCloseTo(400, 2);
353353
expect(result.current.data?.otherTotals.benefits).toBe(0);
354354
});
355355

0 commit comments

Comments
 (0)