-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-9617 Fix Credit Card Fees formula percent precision in PDS Goal Calculator #1796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,11 @@ | |
| DesignationSupportFormType, | ||
| DesignationSupportStatus, | ||
| } from 'src/graphql/types.generated'; | ||
| import { currencyFormat, percentageFormat } from 'src/lib/intlFormat'; | ||
| import { | ||
| currencyFormat, | ||
| numberFormat, | ||
| percentageFormat, | ||
| } from 'src/lib/intlFormat'; | ||
| import { | ||
| OtherExpensesConstants, | ||
| OtherExpensesFields, | ||
|
|
@@ -106,33 +110,41 @@ | |
| { | ||
| id: 'attrition', | ||
| category: t('Attrition'), | ||
| formula: t('Subtotal × {{rate}}', { | ||
| rate: percentageFormat(constants.attritionRate, locale), | ||
| formula: t('Subtotal × {{rate}}%', { | ||
| rate: numberFormat(constants.attritionRate, locale, { | ||
| minimumFractionDigits: 2, | ||
| maximumFractionDigits: 4, | ||
| }), | ||
| }), | ||
| amount: totals.attrition, | ||
| testId: 'other-attrition', | ||
| bold: true, | ||
| }, | ||
| { | ||
| id: 'credit-card-fees', | ||
| category: t('Credit Card Fees'), | ||
| formula: t( | ||
| '(Subtotal + Attrition) ÷ (1 - {{rate}}) - (Subtotal + Attrition)', | ||
| { | ||
| rate: percentageFormat(constants.creditCardFeeRate, locale), | ||
| rate: percentageFormat(constants.creditCardFeeRate, locale, { | ||
| fractionDigits: 2, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
|
||
| }), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }); |
||
| }, | ||
| ), | ||
| amount: totals.creditCardFees, | ||
| testId: 'other-credit-card-fees', | ||
| bold: true, | ||
| }, | ||
| { | ||
| id: 'assessment', | ||
| category: t('Assessment'), | ||
| formula: t( | ||
| '(Subtotal + Attrition + Credit Card Fees) ÷ (1 − {{rate}}) − (Subtotal + Attrition + Credit Card Fees)', | ||
| '(Subtotal + Attrition + Credit Card Fees) ÷ (1 − {{rate}}%) − (Subtotal + Attrition + Credit Card Fees)', | ||
| { | ||
| rate: percentageFormat(constants.adminRate, locale), | ||
| rate: numberFormat(constants.adminRate, locale, { | ||
| minimumFractionDigits: 2, | ||
| maximumFractionDigits: 4, | ||
| }), | ||
|
Check warning on line 147 in src/components/HrTools/PdsGoalCalculator/SupportItem/otherBreakdown.tsx
|
||
| }, | ||
| ), | ||
| amount: totals.assessment, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.