From 0f735ed7dee3dfa7252aff1abfd1c83035154a05 Mon Sep 17 00:00:00 2001 From: Katelyn Grimes Date: Fri, 29 May 2026 14:17:09 -0400 Subject: [PATCH 1/2] Update stop date to end date --- .../DownloadTable/downloadTable.test.tsx | 2 +- .../DownloadTable/downloadTable.tsx | 2 +- .../IntroPage/IntroPage.tsx | 4 ++-- .../Table/PrintTable.test.tsx | 2 +- .../SavingsFundTransfer/Table/PrintTable.tsx | 2 +- .../Table/Row/createTableRow.tsx | 4 ++-- .../Table/TransfersTable.test.tsx | 18 +++++++++--------- .../Table/TransfersTable.tsx | 10 +++++----- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.test.tsx b/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.test.tsx index 9febca4637..43323a274c 100644 --- a/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.test.tsx +++ b/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.test.tsx @@ -18,7 +18,7 @@ const mockHeaders = [ 'Schedule', 'Status', 'Transfer Date', - 'Stop Date', + 'End Date', 'Note', ]; diff --git a/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.tsx b/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.tsx index 7b32d45177..6c48a3038d 100644 --- a/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.tsx +++ b/src/components/HrTools/SavingsFundTransfer/DownloadTable/downloadTable.tsx @@ -73,7 +73,7 @@ export const downloadCSV = ( t('Schedule'), t('Status'), t('Transfer Date'), - t('Stop Date'), + t('End Date'), t('Note'), ]; diff --git a/src/components/HrTools/SavingsFundTransfer/IntroPage/IntroPage.tsx b/src/components/HrTools/SavingsFundTransfer/IntroPage/IntroPage.tsx index 95251ea4d4..62cbbb7e38 100644 --- a/src/components/HrTools/SavingsFundTransfer/IntroPage/IntroPage.tsx +++ b/src/components/HrTools/SavingsFundTransfer/IntroPage/IntroPage.tsx @@ -99,14 +99,14 @@ export const SavingsFundTransfer: React.FC = ({ diff --git a/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.test.tsx b/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.test.tsx index 461b9eaa1a..6812103ac6 100644 --- a/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.test.tsx +++ b/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.test.tsx @@ -72,7 +72,7 @@ describe('PrintTable', () => { ).toBeInTheDocument(); expect(getByRole('cell', { name: 'Jan 1, 2023' })).toBeInTheDocument(); expect( - await findByRole('columnheader', { name: 'Stop Date' }), + await findByRole('columnheader', { name: 'End Date' }), ).toBeInTheDocument(); expect(getByRole('cell', { name: '' })).toBeInTheDocument(); expect( diff --git a/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.tsx b/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.tsx index c373a5fb68..76bbc8280d 100644 --- a/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.tsx +++ b/src/components/HrTools/SavingsFundTransfer/Table/PrintTable.tsx @@ -40,7 +40,7 @@ export const PrintTable: React.FC = ({ transfers, type }) => { {t('Schedule')} {t('Status')} {t('Transfer Date')} - {t('Stop Date')} + {t('End Date')} {t('Note')} diff --git a/src/components/HrTools/SavingsFundTransfer/Table/Row/createTableRow.tsx b/src/components/HrTools/SavingsFundTransfer/Table/Row/createTableRow.tsx index f28df7cb5c..3edab0ef8a 100644 --- a/src/components/HrTools/SavingsFundTransfer/Table/Row/createTableRow.tsx +++ b/src/components/HrTools/SavingsFundTransfer/Table/Row/createTableRow.tsx @@ -230,7 +230,7 @@ export function populateTransferRows(options: Options) { ) : row.endDate ? ( <> { event.stopPropagation(); handleCalendarOpen(row); @@ -259,7 +259,7 @@ export function populateTransferRows(options: Options) { ) : ( <> { event.stopPropagation(); handleCalendarOpen(row); diff --git a/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.test.tsx b/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.test.tsx index 3abf682962..50eaceb3e2 100644 --- a/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.test.tsx +++ b/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.test.tsx @@ -80,7 +80,7 @@ describe('TransferHistoryTable', () => { 'Schedule', 'Status', 'Transfer Date', - 'Stop Date', + 'End Date', 'Note', 'Actions', ]), @@ -119,7 +119,7 @@ describe('TransferHistoryTable', () => { ).toBeInTheDocument(); expect( - within(actionCell).getByRole('button', { name: 'Add Stop Date' }), + within(actionCell).getByRole('button', { name: 'Add End Date' }), ).toBeInTheDocument(); expect( within(actionCell).getByRole('img', { name: 'Stop Transfer' }), @@ -178,7 +178,7 @@ describe('TransferHistoryTable', () => { }); describe('Calendar', () => { - it('opens the calendar when Add Stop Date is clicked', async () => { + it('opens the calendar when Add End Date is clicked', async () => { const { getByRole, findByRole } = render(); const iconRow = getByRole('row', { @@ -187,7 +187,7 @@ describe('TransferHistoryTable', () => { const cells = within(iconRow).getAllByRole('gridcell'); const actionCell = cells[7]; const icon = within(actionCell).getByRole('button', { - name: 'Add Stop Date', + name: 'Add End Date', }); userEvent.click(icon); @@ -205,7 +205,7 @@ describe('TransferHistoryTable', () => { const cells = within(iconRow).getAllByRole('gridcell'); const actionCell = cells[7]; const icon = within(actionCell).getByRole('button', { - name: 'Add Stop Date', + name: 'Add End Date', }); userEvent.click(icon); @@ -231,7 +231,7 @@ describe('TransferHistoryTable', () => { const cells = within(iconRow).getAllByRole('gridcell'); const actionCell = cells[7]; const icon = within(actionCell).getByRole('button', { - name: 'Edit Stop Date', + name: 'Edit End Date', }); userEvent.click(icon); @@ -245,7 +245,7 @@ describe('TransferHistoryTable', () => { userEvent.click(getByRole('button', { name: 'Yes' })); await waitFor(() => expect(mutationSpy).toHaveBeenCalled()); - expect(mockEnqueue).toHaveBeenCalledWith('Stop date updated successfully', { + expect(mockEnqueue).toHaveBeenCalledWith('End date updated successfully', { variant: 'success', }); @@ -261,7 +261,7 @@ describe('TransferHistoryTable', () => { const cells = within(iconRow).getAllByRole('gridcell'); const actionCell = cells[7]; const icon = within(actionCell).getByRole('button', { - name: 'Edit Stop Date', + name: 'Edit End Date', }); userEvent.click(icon); @@ -286,7 +286,7 @@ describe('TransferHistoryTable', () => { userEvent.click(acceptButton); await waitFor(() => expect(mutationSpy).toHaveBeenCalled()); - expect(mockEnqueue).toHaveBeenCalledWith('Stop date updated successfully', { + expect(mockEnqueue).toHaveBeenCalledWith('End date updated successfully', { variant: 'success', }); }); diff --git a/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.tsx b/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.tsx index 9b313a7189..fa7d3f959f 100644 --- a/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.tsx +++ b/src/components/HrTools/SavingsFundTransfer/Table/TransfersTable.tsx @@ -142,12 +142,12 @@ export const TransfersTable: React.FC = ({ ) => { const successMessage = actionType === ActionTypeEnum.Edit - ? t('Stop date updated successfully') - : t('Stop date added successfully'); + ? t('End date updated successfully') + : t('End date added successfully'); const errorMessage = actionType === ActionTypeEnum.Edit - ? t('Failed to update stop date') - : t('Failed to add stop date'); + ? t('Failed to update end date') + : t('Failed to add end date'); try { if (calendarRow) { const recurringEnd: string | null = date ? date.toISO() : null; @@ -228,7 +228,7 @@ export const TransfersTable: React.FC = ({ }, { field: 'endDate', - headerName: t('Stop Date'), + headerName: t('End Date'), width: 145, renderCell: endDate, }, From 5b462a9e172649c5ca4a3a6363c6ea3ab6f993a5 Mon Sep 17 00:00:00 2001 From: Katelyn Grimes Date: Fri, 29 May 2026 14:38:55 -0400 Subject: [PATCH 2/2] Added rounding to MPGA download --- .../CustomExport/CustomExport.test.tsx | 92 ++++++++++++++----- .../CustomExport/CustomExport.tsx | 29 +++++- .../CustomToolbar/CustomToolbar.tsx | 4 +- 3 files changed, 98 insertions(+), 27 deletions(-) diff --git a/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.test.tsx b/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.test.tsx index ebb8a9d8c1..5f02a49d2f 100644 --- a/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.test.tsx +++ b/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.test.tsx @@ -1,7 +1,9 @@ import { ReportTypeEnum } from '../Helper/MPGAReportEnum'; -import { mockData, months } from '../mockData'; +import { DataFields, mockData, months } from '../mockData'; import { createTable, exportToCsv } from './CustomExport'; +const locale = 'en-US'; + const mockSetAttribute = jest.fn(); const mockClick = jest.fn(); @@ -51,7 +53,12 @@ describe('CustomExport', () => { jest.spyOn(link, 'setAttribute').mockImplementation(mockSetAttribute); jest.spyOn(link, 'click').mockImplementation(mockClick); - const data = exportToCsv(mockData.income, ReportTypeEnum.Income, months); + const data = exportToCsv( + mockData.income, + ReportTypeEnum.Income, + months, + locale, + ); expect(mockSetAttribute).toHaveBeenCalledWith( 'href', @@ -69,36 +76,79 @@ describe('CustomExport', () => { }); it('should contain correct data', () => { - const csvData = createTable(mockHeaders, mockData.income); + const csvData = createTable(mockHeaders, mockData.income, locale); expect(csvData).toContain(mockHeaders); expect(csvData[1]).toEqual([ 'Contributions', - 6770, - 6090, - 5770, - 7355, - 8035, - 6575, - 7556, - 8239, - 9799, - 9729, - 13020, - 19215, - 9013, - 108156, + '6770', + '6090', + '5770', + '7355', + '8035', + '6575', + '7556', + '8239', + '9799', + '9729', + '13020', + '19215', + '9013', + '108156', + ]); + }); + + it('should round values to two decimal places', () => { + const decimalData: DataFields[] = [ + { + id: 'rounding-test', + description: 'Rounding', + monthly: [10.234, 10.236, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + average: 9012.567, + total: 108155.555, + }, + ]; + + const csvData = createTable(mockHeaders, decimalData, locale); + + expect(csvData[1]).toEqual([ + 'Rounding', + '10.23', + '10.24', + '-', + '-', + '-', + '-', + '-', + '-', + '-', + '-', + '-', + '-', + '9012.57', + '108155.56', ]); }); it('should display correct totals', () => { - const csvData = createTable(mockHeaders, dataWithTotal); + const csvData = createTable(mockHeaders, dataWithTotal, locale); expect(csvData[csvData.length - 1]).toEqual([ 'Overall Total', - ...monthlyTotals, - overallAverage, - overallTotal, + '6870', + '6190', + '5870', + '7455', + '8135', + '6675', + '7656', + '8239', + '9799', + '9729', + '13020', + '19215', + '9071', + '108856', ]); }); }); diff --git a/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.tsx b/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.tsx index af231e9cbd..fba90937d6 100644 --- a/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.tsx +++ b/src/components/Reports/MPGAIncomeExpensesReport/CustomExport/CustomExport.tsx @@ -2,12 +2,30 @@ import { buildURI } from 'react-csv/lib/core'; import { ReportTypeEnum } from '../Helper/MPGAReportEnum'; import { DataFields } from '../mockData'; -export const createTable = (csvHeader: string[], data: DataFields[]) => { +const round = (value: number, locale: string) => + new Intl.NumberFormat(locale, { + style: 'decimal', + minimumFractionDigits: 2, + maximumFractionDigits: 2, + trailingZeroDisplay: 'stripIfInteger', + useGrouping: false, + }).format(value); + +export const createTable = ( + csvHeader: string[], + data: DataFields[], + locale: string, +) => { const csvData = data.map((item) => { - const monthlyData = item.monthly.map((month) => - month === 0 ? '-' : month, + const monthlyData = item.monthly.map((monthlyAmount) => + monthlyAmount === 0 ? '-' : round(monthlyAmount, locale), ); - return [item.description, ...monthlyData, item.average, item.total]; + return [ + item.description, + ...monthlyData, + round(item.average, locale), + round(item.total, locale), + ]; }); return [csvHeader, ...csvData]; @@ -17,6 +35,7 @@ export const exportToCsv = ( data: DataFields[], reportType: ReportTypeEnum, months: string[], + locale: string, ) => { const title = reportType === ReportTypeEnum.Income @@ -46,7 +65,7 @@ export const exportToCsv = ( ]; const csvHeader = ['Description', ...last12Months, 'Average', 'Total']; - const csvData = createTable(csvHeader, dataWithTotal); + const csvData = createTable(csvHeader, dataWithTotal, locale); const csvBlob = buildURI(csvData, true); diff --git a/src/components/Reports/MPGAIncomeExpensesReport/CustomToolbar/CustomToolbar.tsx b/src/components/Reports/MPGAIncomeExpensesReport/CustomToolbar/CustomToolbar.tsx index 6a4bc6e903..1e9b5dc6c3 100644 --- a/src/components/Reports/MPGAIncomeExpensesReport/CustomToolbar/CustomToolbar.tsx +++ b/src/components/Reports/MPGAIncomeExpensesReport/CustomToolbar/CustomToolbar.tsx @@ -10,6 +10,7 @@ import { ToolbarButton, } from '@mui/x-data-grid'; import { useTranslation } from 'react-i18next'; +import { useLocale } from 'src/hooks/useLocale'; import { exportToCsv } from '../CustomExport/CustomExport'; import { ReportTypeEnum } from '../Helper/MPGAReportEnum'; import { TableCardHead } from '../Tables/TableCardHead'; @@ -27,6 +28,7 @@ export const CustomToolbar: React.FC = ({ months, }) => { const { t } = useTranslation(); + const locale = useLocale(); return ( @@ -71,7 +73,7 @@ export const CustomToolbar: React.FC = ({ /> - exportToCsv(data, type, months)}> + exportToCsv(data, type, months, locale)}>