-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-9374 - Display effective approved salary instead of current salary #1815
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 |
|---|---|---|
|
|
@@ -15,10 +15,14 @@ | |
| import { useAutosaveForm } from 'src/components/Shared/Autosave/AutosaveForm'; | ||
| import { amount } from 'src/lib/yupHelpers'; | ||
| import { AutosaveTextField } from '../../Autosave/AutosaveTextField'; | ||
| import { CalculationFieldsFragment } from '../../SalaryCalculatorContext/SalaryCalculation.generated'; | ||
| import { | ||
| CalculationFieldsFragment, | ||
| useEffectiveSalaryCalculationQuery, | ||
| } from '../../SalaryCalculatorContext/SalaryCalculation.generated'; | ||
| import { useSalaryCalculator } from '../../SalaryCalculatorContext/SalaryCalculatorContext'; | ||
| import { EffectiveDateNote } from '../../Shared/EffectiveDateNote'; | ||
| import { StepCard, StepTableHead } from '../../Shared/StepCard'; | ||
| import { orientSalaryRequest } from '../../Shared/orientSalaryRequest'; | ||
| import { useFormatters } from '../../Shared/useFormatters'; | ||
| import { useCaps } from '../useCaps'; | ||
| import { useSosaBlockOverCap } from '../useSosaBlockOverCap'; | ||
|
|
@@ -35,107 +39,112 @@ | |
| const { isUserSosa, blockOnCap } = useSosaBlockOverCap(); | ||
| const { markValid, markInvalid } = useAutosaveForm(); | ||
|
|
||
| const { data: effectiveData } = useEffectiveSalaryCalculationQuery(); | ||
| const { salary, spouseSalary } = | ||
| orientSalaryRequest( | ||
|
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] The `useEffectiveSalaryCalculationQuery()` + `orientSalaryRequest(..., hcmUser?.staffInfo.personNumber)` idiom now appears in both this card and `SalarySummaryCard`. A small shared `useEffectiveSalaryRequest()` hook would DRY it. Optional. Note: do NOT lift the value into `SalaryCalculatorContext` — the query takes no variables (Apollo dedupes) and the two cards render in different steps, so leaf-level fetching is correct.
|
||
| effectiveData?.salaryRequest, | ||
| hcmUser?.staffInfo.personNumber, | ||
| ) ?? {}; | ||
|
|
||
| // Disable the Continue button while the saved gross exceeds the SOSA cap. | ||
| useEffect(() => { | ||
| if (blockOnCap) { | ||
| markInvalid('over-cap'); | ||
| } else { | ||
| markValid('over-cap'); | ||
| } | ||
| return () => markValid('over-cap'); | ||
| }, [blockOnCap, markValid, markInvalid]); | ||
|
|
||
| const minimumSalaryValue = | ||
| salaryCalculation?.calculations.minimumRequestedSalary; | ||
| const spouseMinimumSalaryValue = | ||
| salaryCalculation?.spouseCalculations?.minimumRequestedSalary; | ||
|
|
||
| const minimumSalary = formatCurrency(minimumSalaryValue); | ||
| const spouseMinimumSalary = formatCurrency(spouseMinimumSalaryValue); | ||
|
|
||
| const renderFormula = ( | ||
| calculations: CalculationFieldsFragment | null | undefined, | ||
| ) => | ||
| t('MHA + {{ min }} - SECA', { | ||
| min: formatCurrency(calculations?.minimumRequiredSalary), | ||
| }); | ||
| const formula = renderFormula(salaryCalculation?.calculations); | ||
| const spouseFormula = renderFormula(salaryCalculation?.spouseCalculations); | ||
|
|
||
| const schema = useMemo( | ||
| () => | ||
| yup.object({ | ||
| salary: amount(t('Requested salary'), t, { | ||
| required: true, | ||
| min: minimumSalaryValue, | ||
| minMessage: t('Requested salary must be at least {{min}}', { | ||
| min: minimumSalary, | ||
| }), | ||
| }), | ||
| spouseSalary: amount(t('Spouse requested salary'), t, { | ||
| required: true, | ||
| min: spouseMinimumSalaryValue, | ||
| minMessage: t('Spouse requested salary must be at least {{min}}', { | ||
| min: spouseMinimumSalary, | ||
| }), | ||
| }), | ||
| }), | ||
| [ | ||
| t, | ||
| minimumSalaryValue, | ||
| minimumSalary, | ||
| spouseMinimumSalaryValue, | ||
| spouseMinimumSalary, | ||
| ], | ||
| ); | ||
|
|
||
| return ( | ||
| <StepCard> | ||
| <CardHeader | ||
| title={t('Requested Salary')} | ||
| subheader={<EffectiveDateNote />} | ||
| /> | ||
| <CardContent> | ||
| <Typography variant="body1" data-testid="RequestedSalaryCard-message"> | ||
| <Trans t={t}> | ||
| Below, enter the annual salary amount you would like to request. | ||
| This salary level includes taxes (local, state, and federal) and | ||
| Minister's Housing Allowance. It does not include either Social | ||
| Security (SECA) or 403b. They will be added in later.{' '} | ||
| </Trans> | ||
| {hcmSpouse ? ( | ||
| <Trans t={t}> | ||
| Because of IRS and Cru requirements, the lowest salary you can | ||
| request is {{ minimumSalary }} ({{ formula }}) for{' '} | ||
| {{ name: hcmUser?.staffInfo.preferredName }} and{' '} | ||
| {{ spouseMinimumSalary }} ({{ spouseFormula }}) for{' '} | ||
| {{ spouseName: hcmSpouse?.staffInfo.preferredName }}. | ||
| </Trans> | ||
| ) : ( | ||
| <Trans t={t}> | ||
| Because of IRS and Cru requirements, the lowest salary you can | ||
| request is {{ minimumSalary }} ({{ formula }}). | ||
| </Trans> | ||
| )}{' '} | ||
| <Trans t={t}> | ||
| As you set your salary level, the amount you receive should reflect | ||
| the amount of time you work in ministry. | ||
| </Trans> | ||
| </Typography> | ||
|
|
||
| <Table> | ||
| <StepTableHead /> | ||
| <TableBody> | ||
| <TableRow> | ||
| <TableCell component="th" scope="row"> | ||
| {t('Current Salary')} | ||
| </TableCell> | ||
| <TableCell> | ||
| {formatCurrency(hcmUser?.currentSalary.grossSalaryAmount)} | ||
|
Comment on lines
-131
to
-134
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. @canac By the ticket description, I wasn't sure if we wanted to include both the Current Salary and the effective Current Requested Salary, or replace the Current Salary. I chose the latter but let me know if I should include both rows.
Contributor
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. Probably not both. I think we wanted to show the current requested (not gross) so they can easily compare it with their new requested salary. |
||
| {t('Current Requested Salary')} | ||
| </TableCell> | ||
| <TableCell>{salary ? formatCurrency(salary) : '–'}</TableCell> | ||
|
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] Empty-state divergence from the sibling card. This renders `–` for "no approved request," but every other money cell in this table — and all of `SalarySummaryCard` — renders `$0.00` (via `formatCurrency`'s `?? 0`). `SalarySummaryCard` handles the same "no effective request" state by omitting the whole "Old" column instead. The dash is defensible (it distinguishes "no prior request" from "$0.00 approved") and arguably an improvement — flagging only so it's a conscious choice rather than an accident. Confirm it's intentional.
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. The '-' aligns with the ticket description, but I can change that. |
||
| {hcmSpouse && ( | ||
| <TableCell> | ||
| {formatCurrency(hcmSpouse.currentSalary.grossSalaryAmount)} | ||
| {spouseSalary ? formatCurrency(spouseSalary) : '–'} | ||
|
Check warning on line 147 in src/components/HrTools/SalaryCalculator/SalaryCalculation/RequestedSalaryCard/RequestedSalaryCard.tsx
|
||
|
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] Truthiness guard hides a legitimate `$0`. `spouseSalary ? formatCurrency(spouseSalary) : '–'` (and line 144) treats `0` as empty, so a real approved `$0` would render `–` instead of `$0.00`. Real-world risk is low — the requested-salary domain has a minimum-salary floor (Yup `min`) — so this may be exactly the intended behavior. If you want strict correctness, use `salary != null ? formatCurrency(salary) : '–'` and add a `salary: 0` test to pin the behavior. Flagged by 4 of 5 agents; author's call.
|
||
| </TableCell> | ||
| )} | ||
| </TableRow> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.