All files / src/features/Settlements/ReconciliationHub/components PerMerchantBreakdown.constants.tsx

100% Statements 9/9
100% Branches 0/0
100% Functions 4/4
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                    2x                         2x         2x     2x       24x 240x               2x       24x 48x            
import GiveText from "@shared/Text/GiveText";
import {
  ReconciliationHubMerchantView,
  ReconciliationHubMerchantsTotals,
} from "../types";
import { formatBpsAsPercent, formatHubAmount } from "../format";
import { StyledBodyCell } from "../../styles";
 
type AmountField = keyof ReconciliationHubMerchantsTotals;
 
export const AMOUNT_COLUMNS: { label: string; field: AmountField }[] = [
  { label: "Processing Volume", field: "processingVolume" },
  { label: "Refunds", field: "refunds" },
  { label: "Chargebacks", field: "chargebacks" },
  { label: "Pre-CB Refunds", field: "preCBRefunds" },
  { label: "Net Sales", field: "netSales" },
  { label: "Purchase Fees", field: "purchaseFees" },
  { label: "Acquirer Total", field: "acquirerTotal" },
  { label: "Paid to Merchant", field: "paidToMerchant" },
  { label: "Reserve Held", field: "reserveHeld" },
  { label: "Available Balance", field: "availableBalance" },
];
 
export const RATE_COLUMNS: { label: string; field: "cbRateBPS" | "preCBRateBPS" }[] = [
  { label: "CB Rate", field: "cbRateBPS" },
  { label: "Pre-CB Rate", field: "preCBRateBPS" },
];
 
export const COLUMN_COUNT = AMOUNT_COLUMNS.length + RATE_COLUMNS.length + 2;
 
/** The amount cells shared by both a merchant row and the Totals row. */
export const renderAmountCells = (
  row: ReconciliationHubMerchantView | ReconciliationHubMerchantsTotals,
  isMobileView?: boolean,
) =>
  AMOUNT_COLUMNS.map((col) => (
    <StyledBodyCell key={col.label} align="center" isMobileView={isMobileView}>
      <GiveText variant="bodyS" color="primary">
        {formatHubAmount(row[col.field])}
      </GiveText>
    </StyledBodyCell>
  ));
 
/** The rate (BPS) cells shared by both a merchant row and the Totals row. */
export const renderRateCells = (
  row: ReconciliationHubMerchantView | ReconciliationHubMerchantsTotals,
  isMobileView?: boolean,
) =>
  RATE_COLUMNS.map((col) => (
    <StyledBodyCell key={col.label} align="center" isMobileView={isMobileView}>
      <GiveText variant="bodyS" color="primary">
        {formatBpsAsPercent(row[col.field])}
      </GiveText>
    </StyledBodyCell>
  ));