From 04ea9a7327a9b8ee66a1d0c959b0fc21d5dd425f Mon Sep 17 00:00:00 2001
From: Justin Gasper
Date: Thu, 19 Nov 2026 07:13:57 +1100
Subject: [PATCH 1/3] fix(PM-6784): show challenge fee in member cost summary
---
.../FlexiTalentCalculatorModal.spec.tsx | 4 +++
.../FlexiTalentCalculatorModal.tsx | 4 +--
.../flexi-talent-calculator.utils.spec.ts | 26 +++++++++++++++++++
.../utils/flexi-talent-calculator.utils.ts | 5 ++++
4 files changed, 37 insertions(+), 2 deletions(-)
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,
From b39adf6b54046b0c6d56899693eb613ba57298fc Mon Sep 17 00:00:00 2001
From: Justin Gasper
Date: Thu, 19 Nov 2026 07:13:58 +1100
Subject: [PATCH 2/3] feat(PM-6783): add goods-sold filters and cost measure
controls
---
src/apps/sales/README.md | 36 ++++
src/apps/sales/src/SalesCustomerTable.tsx | 7 +-
src/apps/sales/src/SalesDashboardTable.tsx | 4 +-
.../sales/src/SalesDashboardsPage.module.scss | 13 +-
src/apps/sales/src/SalesDashboardsPage.tsx | 8 +-
src/apps/sales/src/SalesGoodsSold.spec.tsx | 154 +++++++++++++++++
src/apps/sales/src/SalesGoodsSold.tsx | 158 ++++++++++++++++++
.../sales/src/sales-dashboard.service.spec.ts | 24 +++
src/apps/sales/src/sales-dashboard.service.ts | 21 +++
src/apps/sales/src/useSalesDashboard.ts | 16 +-
10 files changed, 426 insertions(+), 15 deletions(-)
create mode 100644 src/apps/sales/src/SalesGoodsSold.spec.tsx
create mode 100644 src/apps/sales/src/SalesGoodsSold.tsx
diff --git a/src/apps/sales/README.md b/src/apps/sales/README.md
index 65e4099a6..f94b9684c 100644
--- a/src/apps/sales/README.md
+++ b/src/apps/sales/README.md
@@ -481,3 +481,39 @@ 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.
+
+**API dependency — required before enabling this change:** the current
+reports-api-v6 development payments endpoint does not yet implement offering
+filters or return booking costs. Its companion change must:
+
+- Apply repeated `offeringType` parameters with OR semantics to payment events,
+ before customer aggregation, preserving the existing portal/customer scope,
+ latest-version and cancelled-payment rules.
+- Return `filterOptions.offeringType` for the available payment offerings; omit
+ the parameter for ALL, including unknown/unmapped offerings.
+- Return `customerBookingCosts` in the same `MonthlySalesChart` shape as
+ `customerPayments`, adding each payment's challenge fee once, preserving
+ negative adjustments and distinguishing unavailable values from zero.
+- Apply the existing half-open date range to both matrices at payment-event
+ precision, including partial months.
+
+Do not deploy the UI ahead of that API change. The UI tests use the proposed
+response contract; they do not establish that the current API supplies it.
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 && (