Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('DismissalPayPeriodSelection', () => {
})
})

it('sends the period checkDate when available', async () => {
it('does not send checkDate so the server computes it', async () => {
const user = userEvent.setup()
mockCreateOffCyclePayroll.mockResolvedValueOnce({
payrollUnprocessed: { payrollUuid: 'new-payroll-123' },
Expand All @@ -188,7 +188,7 @@ describe('DismissalPayPeriodSelection', () => {
})

const call = mockCreateOffCyclePayroll.mock.calls[0]![0]
expect(call.request.requestBody.checkDate).toBeDefined()
expect(call.request.requestBody.checkDate).toBeUndefined()
})
})

Expand Down Expand Up @@ -233,7 +233,7 @@ describe('DismissalPayPeriodSelection', () => {
})

describe('payroll creation with missing checkDate', () => {
it('computes a fallback checkDate when period has no checkDate', async () => {
it('does not send checkDate even when period has no checkDate', async () => {
mockPayPeriods = [
{
startDate: '2024-12-01',
Expand Down Expand Up @@ -262,9 +262,7 @@ describe('DismissalPayPeriodSelection', () => {
})

const call = mockCreateOffCyclePayroll.mock.calls[0]![0]
const sentCheckDate = call.request.requestBody.checkDate
expect(sentCheckDate).toBeDefined()
expect(sentCheckDate).not.toBe('2024-12-17')
expect(call.request.requestBody.checkDate).toBeUndefined()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { useBase } from '@/components/Base/useBase'
import { componentEvents } from '@/shared/constants'
import { SDKInternalError } from '@/types/sdkError'
import { useComponentDictionary, useI18n } from '@/i18n'
import { addBusinessDays, formatPayPeriodRange } from '@/helpers/dateFormatting'
import { ACH_LEAD_TIME_BUSINESS_DAYS } from '@/components/Payroll/OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation'
import { formatPayPeriodRange } from '@/helpers/dateFormatting'
import type { SelectOption } from '@/components/Common/UI/Select/SelectTypes'

export interface DismissalPayPeriodSelectionProps extends BaseComponentInterface<'Payroll.Dismissal'> {
Expand Down Expand Up @@ -89,10 +88,6 @@ function Root({ companyId, employeeId, payrollId, dictionary }: DismissalPayPeri

const resolvedEmployeeId = employeeId ?? period.employeeUuid

const checkDate = period.checkDate
? new RFCDate(period.checkDate)
: new RFCDate(addBusinessDays(new Date(), ACH_LEAD_TIME_BUSINESS_DAYS))

const response = await createOffCyclePayroll({
request: {
companyId,
Expand All @@ -102,7 +97,6 @@ function Root({ companyId, employeeId, payrollId, dictionary }: DismissalPayPeri
startDate: new RFCDate(period.startDate),
endDate: new RFCDate(period.endDate),
employeeUuids: [resolvedEmployeeId],
checkDate,
},
},
})
Expand Down
Loading