Skip to content

MPDX-9617 Fix Credit Card Fees formula percent precision in PDS Goal Calculator#1796

Merged
wjames111 merged 3 commits into
mainfrom
MPDX-9617
May 21, 2026
Merged

MPDX-9617 Fix Credit Card Fees formula percent precision in PDS Goal Calculator#1796
wjames111 merged 3 commits into
mainfrom
MPDX-9617

Conversation

@wjames111
Copy link
Copy Markdown
Contributor

Description

  • Fixes the Credit Card Fees formula label on the Support Item step of the PDS Goal Calculator
  • The label rounded the configured CREDIT_CARD_FEE_RATE.fee (0.006 / 0.6%) to "1%" because percentageFormat defaulted to 0 fraction digits, while the underlying calculation correctly used 0.6%
  • Pass fractionDigits: 2 to percentageFormat at the credit-card-fees call site so the formula renders "0.60%" and matches the math
  • Adds a regression test pinning the formula text for a fractional fee rate
  • Jira: MPDX-9617

Testing

  • Go to /accountLists/<id>/hrTools/pdsGoalCalculator/<goalId> on staging (impersonate sarah_1.single_staff_applicant@cru.org, designation 1334191) or create a default-type PDS goal
  • Complete the Setup step with any valid pay/hours/benefits
  • Open the Support Item step
  • Check that the Credit Card Fees row formula reads (Subtotal + Attrition) ÷ (1 - 0.60%) - (Subtotal + Attrition) (no more "1%")
  • Confirm the dollar amount is unchanged (the calculation was always correct — only the label was wrong)
  • Run yarn jest src/components/HrTools/PdsGoalCalculator/SupportItem/otherBreakdown.test.tsx and confirm all tests pass

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

🤖 Generated with Claude Code

The Support Item step's Credit Card Fees formula label rounded the
configured fee rate to 0 decimals, showing "1%" instead of the actual
0.6% used in the calculation. Format the rate with 2 fraction digits so
the help text matches the underlying math.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Bundle sizes [mpdx-react]

Compared against 4a5f134

No significant changes found

Copy link
Copy Markdown
Contributor Author

@wjames111 wjames111 left a comment

Choose a reason for hiding this comment

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

Multi-Agent Review Summary — PR #1796

Verdict: APPROVED WITH SUGGESTIONS

Risk: LOW (1/10) — Single display-precision fix in a goal-calculator component, well-scoped and covered by a new unit test. The change correctly keeps rounding at the display boundary via Intl.NumberFormat (per the project's Financial Reporting rule). No calculation logic touched; totals.creditCardFees still uses the raw creditCardFeeRate with full precision.

Agents: Architecture, Testing, Standards, UX, Financial Reporting (5 agents, parallel)

Findings at a glance

Severity Count Summary
Critical (9-10) 0
High (8-8.9) 0
Important (7-7.9) 0
Medium (5-6.9) 1 Cross-rate consistency (3 agents)
Suggestion (<5) 5 Edge-case tests, FYIs

Highlights

  • 3-agent consensus (Architecture + UX + Financial Reporting): Consider extending { fractionDigits: 2 } to the sibling attritionRate (line 110) and adminRate (line 137) calls in the same file. They flow from the same upstream shape (fee: Float!) and the same pdsGoalConstants.ts source — the same misrepresentation bug class can recur there. Out of scope for the MPDX-9617 ticket but worth a follow-up.
  • Testing: New assertion is correct and matches the project's i18next test convention (precedent: same file line ~220 asserts a resolved string for the attrition row). Edge-case coverage could be expanded (0, 0.0001, 0.03).
  • Standards: Clean across every applicable checklist item — named exports, i18n preserved, no any, no debug output, no new Date(), colocated test.
  • Financial Reporting: Fix exemplifies the "round at the display boundary" rule. Calculation path verified untouched.

Notes (informational, not actionable in this PR)

  • .CLAUDE/rules/code-review.md references src/components/Reports/PdsGoalCalculator/** for the Financial Reporting agent trigger, but the actual location is src/components/HrTools/PdsGoalCalculator/**. Worth a separate rules-file update so future automated review fires the right domain agent.

rate: percentageFormat(constants.creditCardFeeRate, locale),
rate: percentageFormat(constants.creditCardFeeRate, locale, {
fractionDigits: 2,
}),
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.

[Medium] **Cross-rate consistency** — 3 agents (Architecture, UX, Financial Reporting) all flag the same point: the sibling `attritionRate` (line 110) and `adminRate` (line 137) still call `percentageFormat` without `{ fractionDigits: 2 }`. They share the same upstream shape (`fee: Float!` in `schema.graphql`) and the same source in `pdsGoalConstants.ts`, so the same misrepresentation bug class can recur there (e.g., a 6.5% attrition rate would render as `7%`). The sibling `PdsSummaryTable.tsx:69` already standardizes on 2-decimal precision for PDS rates.

Out of scope for MPDX-9617 (the ticket is scoped to Credit Card Fees), but recommended as a small follow-up to close the bug class. If you keep the scope tight, a tiny helper at the top of the file would prevent option-object duplication when you do extend it:

const formatRate = (value: number, locale: string) =>
  percentageFormat(value, locale, { fractionDigits: 2 });

{
rate: percentageFormat(constants.creditCardFeeRate, locale),
rate: percentageFormat(constants.creditCardFeeRate, locale, {
fractionDigits: 2,
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] **Sub-basis-point precision is truncated (FYI)** — `fractionDigits: 2` will round anything below 0.005% to `"0.00%"`. For typical credit-card fee rates this is the right trade-off (and is exactly the project's "round at the display boundary" rule), but worth noting that if PDS ever configures rates with more than basis-point precision, the displayed rate won't exactly match the un-rounded value used in the `amount` calculation. No action needed.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

AI Review Auto-Approval

Risk Level: LOW (1/10)
Verdict: APPROVED_WITH_SUGGESTIONS (suggestions posted, no blockers)

This PR was auto-approved because:

  • The multi-agent AI review determined it is low risk
  • No blocking issues were found
  • All suggestions have been posted as review comments for the developer to consider

If you believe this PR needs human review, dismiss this approval and request a review manually.

@zweatshirt
Copy link
Copy Markdown
Contributor

zweatshirt commented May 21, 2026

Sorry this test failure (chunk 2) has been driving me crazy. It's a timeout. I'll fix that, hopefully will be sorted out soon.
00d38f7

@wjames111 wjames111 merged commit fdfd564 into main May 21, 2026
23 of 24 checks passed
@wjames111 wjames111 deleted the MPDX-9617 branch May 21, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants