Skip to content

[No Jira] - Refactor PDS Goal Calculator part-time fees to be amount rather than percent#1817

Merged
github-actions[bot] merged 1 commit into
stagingfrom
mpdx-pds-calc-part-time-fees
Jun 3, 2026
Merged

[No Jira] - Refactor PDS Goal Calculator part-time fees to be amount rather than percent#1817
github-actions[bot] merged 1 commit into
stagingfrom
mpdx-pds-calc-part-time-fees

Conversation

@wjames111

@wjames111 wjames111 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

  • Changes the PDS Goal Calculator's part-time work compensation fee from a percentage applied to gross monthly pay to a flat dollar amount pulled directly from the PART_TIME_WORK_COMPENSATION rate.
  • Renames workCompPercentage to workCompAmount across pdsGoalConstants, OtherExpenses, and their tests to reflect the new semantics.
  • Updates calculateOtherExpenses so the part-time workComp value is the constant amount instead of grossMonthlyPay * workCompPercentage.
  • Updates usePdsSummaryData, buildPdsGoalConstants, and otherBreakdown tests to use the new amount-based value and expected outputs.

Backend work done in this PR

Testing

  • Go to the PDS Goal Calculator for a part-time staff member.
  • Open the Other Expenses / breakdown section and verify the work compensation line shows the flat PART_TIME_WORK_COMPENSATION amount, not a percentage of gross monthly pay.
  • Switch the calculation to full-time and confirm work compensation is 0.
  • Run yarn test src/components/HrTools/PdsGoalCalculator/calculations and confirm OtherExpenses, buildPdsGoalConstants, and usePdsSummaryData suites all pass.
  • Check the PDS goal subtotal/total updates correctly when toggling part-time vs full-time.

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels (Add the label "Preview" to automatically create a preview environment)
  • I have run the Claude Code /pr-review command locally and fixed any relevant suggestions
  • I have requested a review from another person on the project
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Bundle sizes [mpdx-react]

Compared against 351639a

No significant changes found

@wjames111 wjames111 changed the title Refactor PDS Goal Calculator part-time fees to be amount rather than percent [No Jira] - Refactor PDS Goal Calculator part-time fees to be amount rather than percent Jun 3, 2026
@wjames111 wjames111 self-assigned this Jun 3, 2026
@wjames111 wjames111 added Preview Environment Add this label to create an Amplify Preview On Staging Will be merged to the staging branch by Github Actions labels Jun 3, 2026
@github-actions github-actions Bot merged commit e4b94b2 into staging Jun 3, 2026
58 of 63 checks passed
@github-actions github-actions Bot deleted the mpdx-pds-calc-part-time-fees branch June 3, 2026 17:44
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Preview branch generated at https://mpdx-pds-calc-part-time-fees.d3dytjb8adxkk5.amplifyapp.com

@wjames111 wjames111 restored the mpdx-pds-calc-part-time-fees branch June 3, 2026 17:45

@wjames111 wjames111 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 workCompPercentageworkCompAmount 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 formula field while every sibling row (reimbursable-expenses, 403b-contributions, attrition, credit-card-fees, assessment) has one. With the new fixed-amount semantic, a brief formula: 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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] **Semantic drift on `PART_TIME_WORK_COMPENSATION`.** The enum is grouped under `ADDITIONAL_RATES` and the field is called `fee`, but it's now a fixed monthly USD amount, not a rate. A future reader (or a new consumer of `MpdGoalMiscConstantLabelEnum.PartTimeWorkCompensation`) could easily multiply this by a salary and silently produce a wrong number. Since the GraphQL schema is shared with the backend, renaming the enum is out of scope here — but locking the new contract with a one-line comment at the point of use is cheap insurance.
   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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] **Test became near-tautological after rename.** Previously this validated arithmetic (`grossMonthlyPay × workCompPercentage = 4000 × 0.17 = 680`). Now it asserts that `workCompAmount` flows through unchanged when part-time, but the expected value `680` echoes `defaultConstants.workCompAmount: 680`, so the test mostly proves identity.

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 arithmetic

Optional. Flagged by Testing Agent.

// 4000 * 0.17
// fixed amount
expect(result.workComp).toBeCloseTo(680);
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] **Consider adding a regression test that `workComp` no longer depends on `grossMonthlyPay`.** This locks in the new semantics and prevents accidental reintroduction of the percentage formula.
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

On Staging Will be merged to the staging branch by Github Actions Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant