From dd27b599d429bebb8c49f4af06401d76599de7d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Abragamov Date: Thu, 18 Dec 2025 15:18:26 -0500 Subject: [PATCH 1/3] fix: converting split amounts from dollars to cents to match API --- .../PaymentMethod/BankAccountsList.tsx | 7 ++-- .../Employee/PaymentMethod/PaymentMethod.tsx | 32 +++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/components/Employee/PaymentMethod/BankAccountsList.tsx b/src/components/Employee/PaymentMethod/BankAccountsList.tsx index c32702f82..c082d3626 100644 --- a/src/components/Employee/PaymentMethod/BankAccountsList.tsx +++ b/src/components/Employee/PaymentMethod/BankAccountsList.tsx @@ -20,9 +20,10 @@ export function BankAccountsList() { key: 'splitAmount', title: t('allocationColumn'), render: bankAccount => { - return format( - paymentMethod.splits?.find(split => split.uuid === bankAccount.uuid)?.splitAmount ?? 0, - ) + const splitAmount = + paymentMethod.splits?.find(split => split.uuid === bankAccount.uuid)?.splitAmount ?? 0 + const displayValue = paymentMethod.splitBy === 'Amount' ? splitAmount / 100 : splitAmount + return format(displayValue) }, }, ], diff --git a/src/components/Employee/PaymentMethod/PaymentMethod.tsx b/src/components/Employee/PaymentMethod/PaymentMethod.tsx index 2468c3c8f..1c4baf93d 100644 --- a/src/components/Employee/PaymentMethod/PaymentMethod.tsx +++ b/src/components/Employee/PaymentMethod/PaymentMethod.tsx @@ -35,6 +35,16 @@ import { componentEvents, PAYMENT_METHODS, SPLIT_BY } from '@/shared/constants' import { useFlow } from '@/components/Flow/useFlow' import { useComponentDictionary } from '@/i18n/I18n' +const dollarsToCents = (dollars: number | null): number | null => { + if (dollars === null) return null + return Math.round(dollars * 100) +} + +const centsToDollars = (cents: number | null): number | null => { + if (cents === null) return null + return cents / 100 +} + interface PaymentMethodProps extends CommonComponentInterface<'Employee.PaymentMethod'> { employeeId: string defaultValues?: never @@ -89,13 +99,17 @@ const Root = ({ employeeId, className, dictionary, isAdmin = false }: PaymentMet }, []) const defaultValues: CombinedSchemaOutputs = useMemo(() => { + const isAmountSplit = paymentMethod.splitBy === SPLIT_BY.amount return { ...baseDefaultValues, type: paymentMethod.type ?? 'Direct Deposit', splitBy: paymentMethod.splitBy ?? undefined, ...paymentMethod.splits?.reduce( (acc, { uuid, splitAmount, priority }) => ({ - splitAmount: { ...acc.splitAmount, [uuid]: splitAmount ?? null }, + splitAmount: { + ...acc.splitAmount, + [uuid]: isAmountSplit ? centsToDollars(splitAmount ?? null) : (splitAmount ?? null), + }, priority: { ...acc.priority, [uuid]: Number(priority) }, }), { splitAmount: {}, priority: {} }, @@ -181,11 +195,17 @@ const Root = ({ employeeId, className, dictionary, isAdmin = false }: PaymentMet : (paymentMethod.splitBy ?? SPLIT_BY.percentage), splits: payload.isSplit && paymentMethod.splits - ? paymentMethod.splits.map(split => ({ - ...split, - splitAmount: payload.splitAmount[split.uuid], - priority: payload.priority[split.uuid], - })) + ? paymentMethod.splits.map(split => { + const splitAmountValue = payload.splitAmount[split.uuid] ?? null + const isAmountSplit = payload.splitBy === SPLIT_BY.amount + return { + ...split, + splitAmount: isAmountSplit + ? dollarsToCents(splitAmountValue) + : splitAmountValue, + priority: payload.priority[split.uuid], + } + }) : (paymentMethod.splits ?? []), } const paymentMethodResponse = await paymentMethodMutation.mutateAsync({ From 613a83c161510ced3862499e53ce27a77d66c54a Mon Sep 17 00:00:00 2001 From: Dmitriy Abragamov Date: Thu, 18 Dec 2025 15:20:00 -0500 Subject: [PATCH 2/3] fix: converting split amounts from dollars to cents to match API --- src/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.tsx b/src/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.tsx index 595470eb4..f09085b10 100644 --- a/src/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.tsx +++ b/src/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.tsx @@ -64,7 +64,6 @@ function Root({ companyId, wireInId, onEvent }: ConfirmWireDetailsProps) { const [current, send] = useMachine(confirmWireDetailsMachineInstance) function handleEvent(type: EventType, data?: unknown) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call send({ type, payload: data }) if (type === payrollWireEvents.PAYROLL_WIRE_START_TRANSFER) { From 608d786602a0e0c4555abad74612dafea51fd427 Mon Sep 17 00:00:00 2001 From: Dmitriy Abragamov Date: Thu, 18 Dec 2025 17:09:59 -0500 Subject: [PATCH 3/3] chore: pr feedback --- .../Employee/PaymentMethod/BankAccountsList.tsx | 7 ++++++- .../Employee/PaymentMethod/PaymentMethod.tsx | 11 +---------- src/helpers/currencyHelpers.ts | 9 +++++++++ 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 src/helpers/currencyHelpers.ts diff --git a/src/components/Employee/PaymentMethod/BankAccountsList.tsx b/src/components/Employee/PaymentMethod/BankAccountsList.tsx index c082d3626..965d8da6d 100644 --- a/src/components/Employee/PaymentMethod/BankAccountsList.tsx +++ b/src/components/Employee/PaymentMethod/BankAccountsList.tsx @@ -4,6 +4,8 @@ import TrashCanSvg from '@/assets/icons/trashcan.svg?react' import { DataView, useDataView } from '@/components/Common' import useNumberFormatter from '@/hooks/useNumberFormatter' import { HamburgerMenu } from '@/components/Common/HamburgerMenu' +import { SPLIT_BY } from '@/shared/constants' +import { centsToDollars } from '@/helpers/currencyHelpers' export function BankAccountsList() { const { bankAccounts, paymentMethod, mode, handleDelete, isPending } = usePaymentMethod() @@ -22,7 +24,10 @@ export function BankAccountsList() { render: bankAccount => { const splitAmount = paymentMethod.splits?.find(split => split.uuid === bankAccount.uuid)?.splitAmount ?? 0 - const displayValue = paymentMethod.splitBy === 'Amount' ? splitAmount / 100 : splitAmount + const displayValue = + paymentMethod.splitBy === SPLIT_BY.amount + ? (centsToDollars(splitAmount) ?? 0) + : splitAmount return format(displayValue) }, }, diff --git a/src/components/Employee/PaymentMethod/PaymentMethod.tsx b/src/components/Employee/PaymentMethod/PaymentMethod.tsx index 1c4baf93d..7d271217e 100644 --- a/src/components/Employee/PaymentMethod/PaymentMethod.tsx +++ b/src/components/Employee/PaymentMethod/PaymentMethod.tsx @@ -34,16 +34,7 @@ import { useI18n } from '@/i18n' import { componentEvents, PAYMENT_METHODS, SPLIT_BY } from '@/shared/constants' import { useFlow } from '@/components/Flow/useFlow' import { useComponentDictionary } from '@/i18n/I18n' - -const dollarsToCents = (dollars: number | null): number | null => { - if (dollars === null) return null - return Math.round(dollars * 100) -} - -const centsToDollars = (cents: number | null): number | null => { - if (cents === null) return null - return cents / 100 -} +import { centsToDollars, dollarsToCents } from '@/helpers/currencyHelpers' interface PaymentMethodProps extends CommonComponentInterface<'Employee.PaymentMethod'> { employeeId: string diff --git a/src/helpers/currencyHelpers.ts b/src/helpers/currencyHelpers.ts new file mode 100644 index 000000000..9577c1f9d --- /dev/null +++ b/src/helpers/currencyHelpers.ts @@ -0,0 +1,9 @@ +export const dollarsToCents = (dollars: number | null): number | null => { + if (dollars === null) return null + return Math.round(dollars * 100) +} + +export const centsToDollars = (cents: number | null): number | null => { + if (cents === null) return null + return cents / 100 +}