diff --git a/src/apps/sales/README.md b/src/apps/sales/README.md index 65e4099a6..8ab9e1fe1 100644 --- a/src/apps/sales/README.md +++ b/src/apps/sales/README.md @@ -481,3 +481,35 @@ revenue keeps report `00O1K000009GxBtUAK` and the customer matrices. Deploy the companion Reports API changes before the UI. The same shared dashboard also appears in the Reports portal. No browser Salesforce credentials are needed. + + +### PM-6783 goods-sold customer controls + +Goods Sold Customer-Wise has independent inclusive **From date** / **To date** +controls and an offering-type checkbox group (multiple selections, or **ALL**). +**Apply filters** requests the selected range; **Reset filters** returns to the +shared current-fiscal-year payments response. The other charts and the revenue +customer table keep their existing scopes. The API receives UTC midnight for the +start and midnight after the selected To day as the exclusive end. Reversed +ranges are rejected locally. Filtered tables label their sum **Period total**. + +**Member Payment** shows `customerPayments`; **Booking Cost** shows +`customerBookingCosts` (member payments plus challenge fees). Both measures use +the same customer grouping, date/offering selection and Monthly/Quarterly view. +Changing measures does not refetch. Missing booking-cost data is shown explicitly +instead of substituting the member-payment matrix. Failed filtered requests have +an independent retry and superseded requests are cancelled. + +The companion PM-6783 Reports API change supplies `filterOptions.offeringType` +and `customerBookingCosts`. It resolves offerings by billing-account ID through +the linked Salesforce Opportunity, then applies the selection before payment +aggregation. ALL includes unknown/unmapped offerings; Unknown can also be +selected explicitly. Missing fees remain unknown, with a source notice; totals +include known amounts only. The API retains portal scope and existing payment +version/status rules. + +Deploy the companion Reports API change before this UI. Existing Salesforce +credentials and read permissions must allow the billing-account/Opportunity +lookup. A source failure is shown beside this report; selected offerings are +never silently ignored. The date range is limited to 24 months, matching the API. +Repeated quarter labels include the calendar year when a range spans fiscal years. diff --git a/src/apps/sales/src/SalesCustomerTable.tsx b/src/apps/sales/src/SalesCustomerTable.tsx index 12c1790f0..fa04e166f 100644 --- a/src/apps/sales/src/SalesCustomerTable.tsx +++ b/src/apps/sales/src/SalesCustomerTable.tsx @@ -1,6 +1,6 @@ /* The horizontally scrolling table region must be focusable for keyboard scrolling. */ /* eslint-disable jsx-a11y/no-noninteractive-tabindex */ -import { FC, useCallback, useId, useState } from 'react' +import { FC, ReactNode, useCallback, useId, useState } from 'react' import { MonthlySalesChart, SalesDashboardPeriod } from './sales-dashboard.service' import { salesPeriodChart } from './sales-dashboard.utils' @@ -15,6 +15,7 @@ import styles from './SalesDashboardsPage.module.scss' */ const SalesCustomerTable: FC<{ data: MonthlySalesChart; title: string; notices?: string[]; period?: SalesDashboardPeriod + controls?: ReactNode; totalLabel?: string; emptyMessage?: string }> = props => { const data = salesPeriodChart(props.data, props.period ?? 'Monthly') const [expanded, setExpanded] = useState(false) @@ -23,6 +24,7 @@ const SalesCustomerTable: FC<{ return (

{props.title}

+ {props.controls} {props.notices?.map(notice =>

{notice}

)} {data.series.length ? ( - ) :

No customer data in this fiscal year.

} + ) :

{props.emptyMessage ?? 'No customer data in this fiscal year.'}

} {data.series.length > 5 && ( + ), + LoadingSpinner: (props: { message: string }) => {props.message}, +}), { virtual: true }) + +const response: SalesDashboardResponse = { + charts: [], + customerPayments: { + description: '', + id: 'payments', + months: [ + { month: '2026-04-01', values: { a: 100, b: 50 } }, + { month: '2026-05-01', values: { a: 200, b: -20 } }, + ], + series: [{ key: 'a', label: 'Acme' }, { key: 'b', label: 'Beta' }], + stacked: true, + title: '', + unit: 'currency', + }, + filterOptions: { offeringType: ['AI Training', 'Flexible Talent', 'TopGear'] }, + notices: [], +} +response.customerBookingCosts = { + ...response.customerPayments!, + months: [ + { month: '2026-04-01', values: { a: 125, b: 60 } }, + { month: '2026-05-01', values: { a: 250, b: -25 } }, + ], +} +const fetchDashboard = jest.mocked(fetchSalesDashboard) +const source = { data: response, retry: jest.fn() } +const table = (): HTMLElement => screen.getByRole('table', { name: 'Goods Sold Customer-Wise (USD)' }) +const total = (): HTMLElement => within(table()) + .getByRole('row', { name: /^Total / }) +const apply = (): void => { + fireEvent.click(screen.getByRole('button', { name: 'Apply filters' })) +} + +beforeEach(() => { + jest.clearAllMocks() + fetchDashboard.mockResolvedValue(response) +}) + +it('switches member/booking amounts and quarterly totals without refetching', () => { + const view = render() + expect(total()) + .toHaveTextContent('$330.00') + fireEvent.click(screen.getByRole('button', { name: 'Booking Cost' })) + expect(total()) + .toHaveTextContent('$410.00') + expect(within(table()) + .getByRole('row', { name: /^Acme / })) + .toHaveTextContent('$375.00') + view.rerender() + expect(within(total()) + .getAllByText('$410.00')) + .toHaveLength(2) + fireEvent.click(screen.getByRole('button', { name: 'Member Payment' })) + expect(total()) + .toHaveTextContent('$330.00') + expect(fetchDashboard).not.toHaveBeenCalled() +}) + +it('applies both dates and multiple offerings, then resets to the shared source', async () => { + render() + fireEvent.change(screen.getByLabelText('From date'), { target: { value: '2026-04-15' } }) + fireEvent.change(screen.getByLabelText('To date'), { target: { value: '2026-05-20' } }) + fireEvent.click(screen.getByLabelText('AI Training')) + fireEvent.click(screen.getByLabelText('Flexible Talent')) + expect(fetchDashboard).not.toHaveBeenCalled() + apply() + await waitFor(() => expect(fetchDashboard) + .toHaveBeenCalledTimes(1)) + expect(fetchDashboard) + .toHaveBeenLastCalledWith('payments', 'sales', 'close', expect.any(AbortSignal), undefined, { + endDate: '2026-05-20', offeringType: ['AI Training', 'Flexible Talent'], startDate: '2026-04-15', + }) + expect(await screen.findByRole('columnheader', { name: 'Period total' })) + .toBeInTheDocument() + fireEvent.click(screen.getByRole('button', { name: 'Reset filters' })) + expect(screen.getByRole('columnheader', { name: 'Annual' })) + .toBeInTheDocument() + expect(screen.getByLabelText('ALL')) + .toBeChecked() + expect(fetchDashboard.mock.calls[0][3].aborted) + .toBe(true) + expect(fetchDashboard) + .toHaveBeenCalledTimes(1) +}) + +it('rejects reversed dates without requesting or changing the displayed report', () => { + render() + fireEvent.change(screen.getByLabelText('From date'), { target: { value: '2026-05-21' } }) + fireEvent.change(screen.getByLabelText('To date'), { target: { value: '2026-05-20' } }) + apply() + expect(screen.getByRole('alert')) + .toHaveTextContent('From date must be on or before To date.') + expect(fetchDashboard).not.toHaveBeenCalled() + expect(total()) + .toHaveTextContent('$330.00') +}) + +it('cancels superseded filters and retries failed filtered requests with the same scope', async () => { + fetchDashboard.mockImplementationOnce(() => new Promise(() => { /* Superseded request. */ })) + fetchDashboard.mockRejectedValueOnce(new Error('offline')) + const view = render() + apply() + const firstSignal = fetchDashboard.mock.calls[0][3] + fireEvent.click(screen.getByLabelText('TopGear')) + apply() + expect(firstSignal.aborted) + .toBe(true) + expect(await screen.findByRole('alert')) + .toHaveTextContent('Member payments could not be loaded') + fireEvent.click(screen.getByRole('button', { name: 'Try again' })) + await screen.findByRole('table', { name: 'Goods Sold Customer-Wise (USD)' }) + expect(fetchDashboard.mock.calls[2][5]?.offeringType) + .toEqual(['TopGear']) + view.rerender() + await waitFor(() => expect(fetchDashboard) + .toHaveBeenCalledTimes(4)) + view.unmount() + expect(fetchDashboard.mock.calls[3][3].aborted) + .toBe(true) +}) + +it('shows an empty filtered result and does not substitute payments for missing booking costs', async () => { + fetchDashboard.mockResolvedValue({ ...response, customerPayments: { ...response.customerPayments!, series: [] } }) + render() + fireEvent.click(screen.getByRole('button', { name: 'Booking Cost' })) + expect(screen.getByText('Booking cost details are unavailable for this source.')) + .toBeInTheDocument() + expect(screen.queryByRole('table')).not.toBeInTheDocument() + fireEvent.click(screen.getByRole('button', { name: 'Member Payment' })) + apply() + expect(await screen.findByText('No customer data matches these filters.')) + .toBeInTheDocument() +}) + +it('rejects ranges beyond the API limit without refetching', () => { + render() + fireEvent.change(screen.getByLabelText('From date'), { target: { value: '2025-01-01' } }) + fireEvent.change(screen.getByLabelText('To date'), { target: { value: '2027-02-01' } }) + apply() + expect(screen.getByRole('alert')) + .toHaveTextContent('Choose a range of no more than 24 months.') + expect(fetchDashboard) + .not.toHaveBeenCalled() +}) + +it('distinguishes repeated quarters when the date range spans fiscal years', () => { + const data = { + ...response, + customerPayments: { + ...response.customerPayments!, + months: [{ month: '2026-04-01', values: { a: 100 } }, { month: '2027-04-01', values: { a: 200 } }], + }, + } + render() + expect(screen.getByRole('columnheader', { name: 'Q1 2026' })) + .toBeInTheDocument() + expect(screen.getByRole('columnheader', { name: 'Q1 2027' })) + .toBeInTheDocument() +}) diff --git a/src/apps/sales/src/SalesGoodsSold.tsx b/src/apps/sales/src/SalesGoodsSold.tsx new file mode 100644 index 000000000..d413e252a --- /dev/null +++ b/src/apps/sales/src/SalesGoodsSold.tsx @@ -0,0 +1,164 @@ +/* Each control captures its own selected value. */ +/* eslint react/jsx-no-bind: ["error", { "allowArrowFunctions": true }] */ +import { FC, FormEvent, useState } from 'react' + +import { Button, LoadingSpinner } from '~/libs/ui' + +import { + SalesCustomerPaymentFilters, + SalesDashboardPeriod, + SalesDashboardPortal, +} from './sales-dashboard.service' +import { salesFiscalYear } from './sales-fiscal-year' +import { SalesDashboardSource, useSalesDashboard } from './useSalesDashboard' +import SalesCustomerTable from './SalesCustomerTable' +import styles from './SalesDashboardsPage.module.scss' + +const title = 'Goods Sold Customer-Wise' + +/** Keeps goods-sold filters independent of the shared fiscal-year payment charts. */ +const SalesGoodsSold: FC<{ + source: SalesDashboardSource; portal: SalesDashboardPortal; refreshKey: number; period: SalesDashboardPeriod +}> = props => { + const fiscalYear = salesFiscalYear() + const [startDate, setStartDate] = useState(`${fiscalYear - 1}-04-01`) + const [endDate, setEndDate] = useState(`${fiscalYear}-03-31`) + const [offeringType, setOfferingType] = useState([]) + const [filters, setFilters] = useState() + const [bookingCost, setBookingCost] = useState(false) + const [validationError, setValidationError] = useState('') + const filtered = useSalesDashboard( + 'payments', + props.portal, + 'close', + props.refreshKey, + undefined, + filters, + !!filters, + ) + const source = filters ? filtered : props.source + const data = bookingCost ? source.data?.customerBookingCosts : source.data?.customerPayments + const offerings = [...new Set([ + ...(props.source.data?.filterOptions?.offeringType ?? []), + ...(source.data?.filterOptions?.offeringType ?? []), + ...offeringType, + ])].sort() + const apply = (event: FormEvent): void => { + event.preventDefault() + if (!startDate || !endDate || startDate > endDate) { + setValidationError('From date must be on or before To date.') + return + } + + const days = (Date.parse(`${endDate}T00:00:00Z`) - Date.parse(`${startDate}T00:00:00Z`)) / 86400000 + 1 + if (days > 732) { + setValidationError('Choose a range of no more than 24 months.') + return + } + + setValidationError('') + setFilters({ endDate, offeringType, startDate }) + } + + const reset = (): void => { + setStartDate(`${fiscalYear - 1}-04-01`) + setEndDate(`${fiscalYear}-03-31`) + setOfferingType([]) + setFilters(undefined) + setValidationError('') + } + + const controls = ( + <> +
+
+ + +
+
+ Goods sold offering type + + {offerings.map(offering => ( + + ))} +
+ {validationError &&

{validationError}

} +
+ + +
+
+
+ + +
+

{bookingCost ? 'Booking Cost includes member payments and challenge fees.' : 'Member payments only.'}

+ {filters && ( +

+ {`Applied dates: ${filters.startDate} through ${filters.endDate} (UTC, inclusive).`} + {` Offering types: ${filters.offeringType.join(', ') || 'ALL'}.`} +

+ )} + + ) + + return data ? ( + + ) : ( +
+

{title}

+ {controls} + {source.error ? ( +
+

{source.error}

+ +
+ ) : source.data ? ( + <> + {source.data.notices.map(notice =>

{notice}

)} +

+ {bookingCost ? 'Booking cost details are unavailable for this source.' + : 'Customer details are unavailable for this source.'} +

+ + ) : } +
+ ) +} + +export default SalesGoodsSold diff --git a/src/apps/sales/src/sales-dashboard.service.spec.ts b/src/apps/sales/src/sales-dashboard.service.spec.ts index 3b479e962..e04a0feab 100644 --- a/src/apps/sales/src/sales-dashboard.service.spec.ts +++ b/src/apps/sales/src/sales-dashboard.service.spec.ts @@ -102,3 +102,27 @@ describe('Sales dashboard fiscal year requests', () => { ]) }) }) + +describe('Goods sold date and offering filters', () => { + it.each([ + ['2028-02-29', '2028-03-01T00:00:00.000Z'], + ['2026-12-31', '2027-01-01T00:00:00.000Z'], + ])('includes the full To date %s in UTC', (endDate, exclusiveEnd) => { + jest.clearAllMocks() + const signal = new AbortController().signal + fetchSalesDashboard('payments', 'sales', 'close', signal, undefined, { + endDate, + offeringType: ['AI Training', 'Flexible Talent'], + startDate: '2026-05-15', + }) + const params = new URL(String(jest.mocked(xhrGetAsync).mock.calls[0][0])).searchParams + expect(params.get('startDate')) + .toBe('2026-05-15T00:00:00.000Z') + expect(params.get('endDate')) + .toBe(exclusiveEnd) + expect(params.getAll('offeringType')) + .toEqual(['AI Training', 'Flexible Talent']) + expect(params.get('portal')) + .toBe('sales') + }) +}) diff --git a/src/apps/sales/src/sales-dashboard.service.ts b/src/apps/sales/src/sales-dashboard.service.ts index ba6bce277..396a99074 100644 --- a/src/apps/sales/src/sales-dashboard.service.ts +++ b/src/apps/sales/src/sales-dashboard.service.ts @@ -11,6 +11,13 @@ export type SalesAccountCategory = 'External Revenue' | 'Through Wipro' | 'Wipro export type SalesRevenueOfferingType = 'AI Training' | 'Crowd Powered Outcomes' | 'Crowd Powered Innovation' | 'Flexible Talent' | 'TopGear' | 'TaaS Ops' +/** Inclusive calendar dates and offering selections for the goods-sold customer report. */ +export interface SalesCustomerPaymentFilters { + startDate: string + endDate: string + offeringType: string[] +} + /** Dimension whose categories become chart series and monthly table columns. */ export type SalesDashboardGroupBy = 'offeringType' | 'dealCategory' | 'customerType' | 'stage' | 'fyClosure' @@ -39,6 +46,9 @@ export interface SalesDashboardResponse extends SalesCustomerRevenue { notices: string[] /** Every customer before top-five/Other grouping, used for the monthly payments matrix. */ customerPayments?: MonthlySalesChart + /** Same customer/payment scope, with challenge fees added once per payment. */ + customerBookingCosts?: MonthlySalesChart + filterOptions?: { offeringType: string[] } /** Offering-scoped matrices, with account-category intersections calculated from revenue detail rows. */ customerRevenueByOfferingType?: Partial> } @@ -52,6 +62,7 @@ export interface SalesDashboardResponse extends SalesCustomerRevenue { * @param dateBasis Date field for pipeline monthly grouping. * @param signal Cancels superseded or unmounted requests. * @param groupBy Business breakdown dimension; all category values remain visible. + * @param customerFilters Inclusive date bounds and offering selections for an independent goods-sold request. * @returns Monthly chart definitions and any source limitations. * @throws Propagates network and authorization errors for the section's inline retry state. */ @@ -61,6 +72,7 @@ export function fetchSalesDashboard( dateBasis: 'close' | 'created', signal: AbortSignal, groupBy?: SalesDashboardGroupBy, + customerFilters?: SalesCustomerPaymentFilters, ): Promise { const fiscalYear = salesFiscalYear() - 1 const params = new URLSearchParams({ @@ -72,6 +84,15 @@ export function fetchSalesDashboard( .toISOString(), }) if (groupBy) params.set('groupBy', groupBy) + if (customerFilters) { + params.set('startDate', `${customerFilters.startDate}T00:00:00.000Z`) + // The date picker includes the entire To day; the API accepts an exclusive UTC end. + const exclusiveEnd = new Date(`${customerFilters.endDate}T00:00:00.000Z`) + exclusiveEnd.setUTCDate(exclusiveEnd.getUTCDate() + 1) + params.set('endDate', exclusiveEnd.toISOString()) + customerFilters.offeringType.forEach(offering => params.append('offeringType', offering)) + } + return xhrGetAsync( `${EnvironmentConfig.REPORTS_API}/sales-dashboard/${section}?${params.toString()}`, undefined, diff --git a/src/apps/sales/src/useSalesDashboard.ts b/src/apps/sales/src/useSalesDashboard.ts index 4551942f0..122557580 100644 --- a/src/apps/sales/src/useSalesDashboard.ts +++ b/src/apps/sales/src/useSalesDashboard.ts @@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from 'react' import { fetchSalesDashboard, + SalesCustomerPaymentFilters, SalesDashboardGroupBy, SalesDashboardPortal, SalesDashboardResponse, @@ -33,6 +34,8 @@ export interface SalesDashboardSource { * @param dateBasis Selected bookings/pipeline date field; other sources always use close. * @param refreshKey Increments when the user refreshes all sources. * @param groupBy Independent card breakdown; changes cancel superseded requests. + * @param customerFilters Stable applied goods-sold filters, separate from the shared payment source. + * @param enabled Whether to load; false lets goods sold reuse the existing unfiltered source. * @returns Current response/error and a retry callback; superseded results are ignored. * @throws Does not throw; transport errors are exposed as user-facing messages. */ @@ -42,18 +45,23 @@ export function useSalesDashboard( dateBasis: 'close' | 'created', refreshKey: number, groupBy?: SalesDashboardGroupBy, + customerFilters?: SalesCustomerPaymentFilters, + enabled: boolean = true, ): SalesDashboardSource { const [data, setData] = useState() const [error, setError] = useState() const [retryKey, setRetryKey] = useState(0) const basis = ['pipeline', 'bookings'].includes(section) ? dateBasis : 'close' useEffect(() => { + if (!enabled) return undefined const controller = new AbortController() setData(undefined) setError(undefined) - const request = groupBy - ? fetchSalesDashboard(section, portal, basis, controller.signal, groupBy) - : fetchSalesDashboard(section, portal, basis, controller.signal) + const request = customerFilters + ? fetchSalesDashboard(section, portal, basis, controller.signal, groupBy, customerFilters) + : groupBy + ? fetchSalesDashboard(section, portal, basis, controller.signal, groupBy) + : fetchSalesDashboard(section, portal, basis, controller.signal) request .then(response => { if (!controller.signal.aborted) { @@ -68,7 +76,7 @@ export function useSalesDashboard( : `${dashboardTitles[section]} could not be loaded. Please try again.`) }) return () => controller.abort() - }, [section, portal, basis, refreshKey, retryKey, groupBy]) + }, [section, portal, basis, refreshKey, retryKey, groupBy, customerFilters, enabled]) const retry = useCallback(() => setRetryKey(value => value + 1), []) return { data, error, retry } } diff --git a/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.spec.tsx b/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.spec.tsx index df6fe675a..64111bb47 100644 --- a/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.spec.tsx +++ b/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.spec.tsx @@ -220,6 +220,10 @@ describe('FlexiTalentCalculatorModal', () => { expect(screen.getByLabelText('Member Cost (USD)')) .toHaveValue('104000') + expect(screen.getByText(/Challenge fee: USD 116,000/)) + .toBeInTheDocument() + expect(screen.queryByText(/Member Hourly Rate \(based on Actual Cost\)/)) + .not.toBeInTheDocument() expect(screen.getByLabelText('Actual Cost (USD)')) .toHaveValue('161260') diff --git a/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.tsx b/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.tsx index 5464409d9..7790ca5a0 100644 --- a/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.tsx +++ b/src/apps/work/src/lib/components/FlexiTalentCalculatorModal/FlexiTalentCalculatorModal.tsx @@ -661,8 +661,8 @@ export const FlexiTalentCalculatorModal: FC = ( {' · '} {`Member Monthly Rate: USD ${formatCalculatorAmount(result.memberMonthlyRate)}`} {' · '} - {`Member Hourly Rate (based on Actual Cost): USD ${ - formatCalculatorAmount(result.actualRate) + {`Challenge fee: USD ${ + formatCalculatorAmount(result.challengeFee) }`}

diff --git a/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.spec.ts b/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.spec.ts index 904ec6466..6966a09c7 100644 --- a/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.spec.ts +++ b/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.spec.ts @@ -17,6 +17,32 @@ const baseInputs: FlexiTalentCalculatorInputs = { } describe('calculateFlexiTalentCosts', () => { + it.each([ + [false, 40000, 20000], + [true, 40000, 18000], + [false, 20000, 0], + [true, 20000, -2000], + ])('calculates challenge fee with referral=%s and booking cost=%s', (referral, bookingCost, expected) => { + const result = calculateFlexiTalentCosts({ + ...baseInputs, + commercialInput: { field: 'bookingCost', value: bookingCost }, + referral, + }) + expect(result.challengeFee) + .toBe(expected) + }) + + it('leaves the challenge fee unavailable until both costs are known', () => { + expect(calculateFlexiTalentCosts(baseInputs).challengeFee) + .toBeUndefined() + expect(calculateFlexiTalentCosts({ + ...baseInputs, + commercialInput: { field: 'bookingCost', value: 40000 }, + memberInput: undefined, + }).challengeFee) + .toBeUndefined() + }) + it('derives the member costs', () => { const result = calculateFlexiTalentCosts({ ...baseInputs, referral: true }) diff --git a/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.ts b/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.ts index 59614ee74..87d0616bd 100644 --- a/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.ts +++ b/src/apps/work/src/lib/utils/flexi-talent-calculator.utils.ts @@ -59,6 +59,8 @@ export interface FlexiTalentCalculatorResult { actualRate?: number bookingCost?: number bookingRate?: number + /** Booking cost less total member cost, including any referral fee. */ + challengeFee?: number /** Fraction, e.g. 0.733. */ costTransferRate?: number memberCost?: number @@ -257,6 +259,9 @@ export function calculateFlexiTalentCosts( actualRate: divide(actualCost, totalBillingHours), bookingCost, bookingRate: divide(bookingCost, totalBillingHours), + challengeFee: isFiniteNumber(bookingCost) && isFiniteNumber(totalMemberCost) + ? bookingCost - totalMemberCost + : undefined, costTransferRate, memberCost, memberMonthlyRate,