diff --git a/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx b/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx index 98a561d6c0..e6ea6ba6d4 100644 --- a/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx +++ b/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx @@ -21,7 +21,11 @@ import { } from 'recharts'; import { CHART_COLORS } from '../../../components/charts/colors'; -import { formatDecimal, formatPriceRange } from '../../../defaults/formatters'; +import { + formatCurrency, + formatDecimal, + formatPriceRange +} from '../../../defaults/formatters'; import { ApiEndpoints } from '../../../enums/ApiEndpoints'; import { ModelType } from '../../../enums/ModelType'; import { useTable } from '../../../hooks/UseTable'; @@ -32,7 +36,7 @@ import { InvenTreeTable } from '../../../tables/InvenTreeTable'; import { NoPricingData } from './PricingPanel'; // Display BOM data as a pie chart -function BomPieChart({ data }: { data: any[] }) { +function BomPieChart({ data, currency }: { data: any[]; currency: string }) { return ( @@ -71,12 +75,18 @@ function BomPieChart({ data }: { data: any[] }) { } // Display BOM data as a bar chart -function BomBarChart({ data }: { data: any[] }) { +function BomBarChart({ data, currency }: { data: any[]; currency: string }) { return ( - + + formatCurrency(value, { + currency: currency + })?.toString() ?? '' + } + /> {bomPricingData.length > 0 ? ( - {chartType == 'bar' && } - {chartType == 'pie' && } + {chartType == 'bar' && ( + + )} + {chartType == 'pie' && ( + + )} { + if (table.records.length === 0) { + return ''; + } + return table.records[0].currency; + }, [table.records]); + return ( <> {newPriceBreak.modal} @@ -166,7 +173,13 @@ export default function PriceBreakPanel({ - + + formatCurrency(value, { + currency: currency + })?.toString() ?? '' + } + /> - + + formatCurrency(value, { + currency: pricing?.currency + })?.toString() ?? '' + } + /> { + if (table.records.length === 0) { + return ''; + } + return table.records[0].purchase_price_currency; + }, [table.records]); + const purchaseHistoryData = useMemo(() => { return table.records.map((record: any) => { return { @@ -126,7 +133,13 @@ export default function PurchaseHistoryPanel({ - + + formatCurrency(value, { + currency: currency + })?.toString() ?? '' + } + /> { + if (table.records.length === 0) { + return ''; + } + return table.records[0].sale_price_currency; + }, [table.records]); + const saleHistoryData = useMemo(() => { return table.records.map((record: any) => { return { @@ -90,7 +97,13 @@ export default function SaleHistoryPanel({ part }: { part: any }): ReactNode { - + + formatCurrency(value, { + currency: currency + })?.toString() ?? '' + } + /> { + if (table.records.length === 0) { + return ''; + } + return table.records[0].currency; + }, [table.records]); + const supplierPricingData = useMemo(() => { return table.records.map((record: any) => { return { @@ -58,7 +66,13 @@ export default function SupplierPricingPanel({ part }: { part: any }) { - + + formatCurrency(value, { + currency: currency + })?.toString() ?? '' + } + /> - + + formatCurrency(value, { + currency: pricing?.currency + })?.toString() ?? '' + } + />