[No Jira] - Refactor PDS Goal Calculator part-time fees to be amount rather than percent#1817
Conversation
Bundle sizes [mpdx-react]Compared against 351639a No significant changes found |
|
Preview branch generated at https://mpdx-pds-calc-part-time-fees.d3dytjb8adxkk5.amplifyapp.com |
wjames111
left a comment
There was a problem hiding this comment.
Multi-Agent Review Summary
Verdict: CLEAN (no in-diff findings ≥ severity 5)
Risk: LOW (3/10) — small targeted refactor; no auth/cache/migration/GraphQL changes.
This PR renames workCompPercentage → workCompAmount and replaces grossMonthlyPay × rate with a fixed dollar passthrough in the PDS Goal Calculator. The rename is consistent across both source files and all four test files. Test math was recomputed by hand and verified (subtotal 3413.333 → attrition 204.8 → creditCardFees ≈230.94 → assessment ≈524.87 → overallTotal ≈4373.95). Both branches of the new conditional are covered.
Agents launched
4 specialized reviewers in parallel (Standard mode):
- Architecture · Testing & Quality · Standards Compliance · Financial Reporting (domain)
Summary
| Agent | Critical | High | Important | Suggestions |
|---|---|---|---|---|
| Architecture | 0 | 0 | 0 | 3 |
| Testing & Quality | 0 | 0 | 0 | 2 |
| Standards | 0 | 0 | 0 | 0 |
| Financial Reporting | 0 | 0 | 1 (related file) | 1 |
| Total | 0 | 0 | 1 (related) | 6 |
Findings on Related Files (Not in This PR)
Identified during the review on files NOT directly modified by this PR. They cannot be posted as line comments and are informational only.
[Important] src/components/HrTools/PdsGoalCalculator/PdsGoalCalculatorTestWrapper.tsx:259 — stale fixture
- Severity: 6.5/10
- Flagged by: Financial Reporting Agent
- The shared PDS test wrapper still mocks
PartTimeWorkCompensation.fee = 0.17. Under the OLD semantic this meant 17 % of gross monthly pay (~$680/mo). Under this PR's NEW semantic it means $0.17 per month — effectively zero work-comp expense. - No tests fail today because no existing part-time test goes through this wrapper for work-comp totals, but the next part-time test written against the shared wrapper will silently compute workComp = $0.17 and produce a wrong total goal.
- Recommended fix (one line):
- fee: 0.17,
+ fee: 20.35, // dollar amount per new semantic; matches buildPdsGoalConstants.test.ts default- Strong recommendation to include this fix in the PR.
[Suggestion] src/components/HrTools/PdsGoalCalculator/SupportItem/otherBreakdown.tsx:80-86 — UX consistency
- Severity: 3.5/10
- Flagged by: Architecture + Financial agents (cross-referenced)
- Work-Comp row omits the
formulafield while every sibling row (reimbursable-expenses,403b-contributions,attrition,credit-card-fees,assessment) has one. With the new fixed-amount semantic, a briefformula: t('Fixed monthly work comp for part-time staff')would clarify to staff that this number comes from a server constant they cannot adjust. - Pre-existing UX inconsistency — out of scope for this PR; worth a follow-up.
Cross-calculator consistency (verified clean)
Financial Reporting agent traced every consumer of PART_TIME_WORK_COMPENSATION.fee across src/, pages/, and pages/api/Schema/. The only production consumer is pdsGoalConstants.ts. The MPD Goal Calculator (src/components/Reports/GoalCalculator/) is currently empty — no parallel implementation to drift from. All user-facing labels (public/locales/en/, PdsSummaryTable.tsx, otherBreakdown.tsx) use neutral wording ("Work Comp", "Workers Compensation") — no "Percentage"/"Rate" wording remains that would mislabel a dollar amount.
Standards checklist
All items either PASS or N/A for this scope. Named exports preserved, no any introduced, null guard in buildPdsGoalConstants preserved (returns null when the constant is missing — prevents silent $0 work-comp from masking misconfiguration), no debug output, no new Date(), rounding stays at the display boundary.
|
|
||
| const employerFicaRate = additionalRates?.EMPLOYER_FICA_RATE?.fee; | ||
| const workCompPercentage = additionalRates?.PART_TIME_WORK_COMPENSATION?.fee; | ||
| const workCompAmount = additionalRates?.PART_TIME_WORK_COMPENSATION?.fee; |
There was a problem hiding this comment.
const employerFicaRate = additionalRates?.EMPLOYER_FICA_RATE?.fee;
+ // PART_TIME_WORK_COMPENSATION.fee is a fixed monthly USD amount, not a rate
+ // (despite the enum's placement under ADDITIONAL_RATES and the `.fee` field name).
const workCompAmount = additionalRates?.PART_TIME_WORK_COMPENSATION?.fee;Flagged by Architecture Agent.
| const result = calculateOtherExpenses(partTime(), defaultConstants); | ||
| // 4000 * 0.17 | ||
| // fixed amount | ||
| expect(result.workComp).toBeCloseTo(680); |
There was a problem hiding this comment.
It still meaningfully exercises the part-time branch, so this is not a defect. If you want to make intent obvious, use a constant override:
const result = calculateOtherExpenses(partTime(), {
...defaultConstants,
workCompAmount: 123.45,
});
expect(result.workComp).toBe(123.45); // identity, not arithmeticOptional. Flagged by Testing Agent.
| // 4000 * 0.17 | ||
| // fixed amount | ||
| expect(result.workComp).toBeCloseTo(680); | ||
| }); |
There was a problem hiding this comment.
it('does not depend on grossMonthlyPay for part-time', () => {
const lowPay = calculateOtherExpenses(partTime(), { ...defaultConstants, grossMonthlyPay: 100 });
const highPay = calculateOtherExpenses(partTime(), { ...defaultConstants, grossMonthlyPay: 10000 });
expect(lowPay.workComp).toBe(highPay.workComp);
});Optional. Flagged by Testing Agent.
Description
PART_TIME_WORK_COMPENSATIONrate.workCompPercentagetoworkCompAmountacrosspdsGoalConstants,OtherExpenses, and their tests to reflect the new semantics.calculateOtherExpensesso the part-timeworkCompvalue is the constant amount instead ofgrossMonthlyPay * workCompPercentage.usePdsSummaryData,buildPdsGoalConstants, andotherBreakdowntests to use the new amount-based value and expected outputs.Backend work done in this PR
Testing
PART_TIME_WORK_COMPENSATIONamount, not a percentage of gross monthly pay.0.yarn test src/components/HrTools/PdsGoalCalculator/calculationsand confirmOtherExpenses,buildPdsGoalConstants, andusePdsSummaryDatasuites all pass.Checklist:
/pr-reviewcommand locally and fixed any relevant suggestions