Fixes for metrics calculations

This commit is contained in:
2026-02-07 21:34:42 -05:00
parent 9b2f9016f6
commit 12cc7a4639
18 changed files with 267 additions and 169 deletions
@@ -127,6 +127,7 @@ export function CapitalEfficiency() {
tickFormatter={formatCurrency}
tick={{ fontSize: 11 }}
type="number"
label={{ value: 'Stock Investment', position: 'insideBottom', offset: -5, fontSize: 12, fill: '#888' }}
/>
<YAxis
dataKey="profit30d"
@@ -134,6 +135,7 @@ export function CapitalEfficiency() {
tickFormatter={formatCurrency}
tick={{ fontSize: 11 }}
type="number"
label={{ value: 'Profit (30d)', angle: -90, position: 'insideLeft', offset: 10, fontSize: 12, fill: '#888' }}
/>
<ZAxis dataKey="productCount" range={[40, 400]} name="Products" />
<Tooltip
@@ -220,7 +220,6 @@ export function ProductDetail({ productId, onClose }: ProductDetailProps) {
<InfoItem label="Current Price" value={formatCurrency(product.currentPrice)} />
<InfoItem label="Regular Price" value={formatCurrency(product.currentRegularPrice)} />
<InfoItem label="Cost Price" value={formatCurrency(product.currentCostPrice)} />
<InfoItem label="Landing Cost" value={formatCurrency(product.currentLandingCostPrice)} />
</CardContent>
</Card>
<Card>
@@ -119,7 +119,6 @@ const BASE_FILTER_OPTIONS: FilterOption[] = [
{ id: "currentPrice", label: "Current Price", type: "number", group: "Pricing", operators: ["=", ">", ">=", "<", "<=", "between"] },
{ id: "currentRegularPrice", label: "Regular Price", type: "number", group: "Pricing", operators: ["=", ">", ">=", "<", "<=", "between"] },
{ id: "currentCostPrice", label: "Cost Price", type: "number", group: "Pricing", operators: ["=", ">", ">=", "<", "<=", "between"] },
{ id: "currentLandingCostPrice", label: "Landing Cost", type: "number", group: "Pricing", operators: ["=", ">", ">=", "<", "<=", "between"] },
// Valuation Group
{ id: "currentStockCost", label: "Current Stock Cost", type: "number", group: "Valuation", operators: ["=", ">", ">=", "<", "<=", "between"] },
@@ -95,7 +95,6 @@ export const AVAILABLE_COLUMNS: ColumnDef[] = [
{ key: 'currentPrice', label: 'Price', group: 'Pricing', format: (v) => v === 0 ? '0' : v ? v.toFixed(2) : '-' },
{ key: 'currentRegularPrice', label: 'Regular Price', group: 'Pricing', format: (v) => v === 0 ? '0' : v ? v.toFixed(2) : '-' },
{ key: 'currentCostPrice', label: 'Cost', group: 'Pricing', format: (v) => v === 0 ? '0' : v ? v.toFixed(2) : '-' },
{ key: 'currentLandingCostPrice', label: 'Landing Cost', group: 'Pricing', format: (v) => v === 0 ? '0' : v ? v.toFixed(2) : '-' },
{ key: 'currentStockCost', label: 'Stock Cost', group: 'Valuation', format: (v) => v === 0 ? '0' : v ? v.toFixed(2) : '-' },
{ key: 'currentStockRetail', label: 'Stock Retail', group: 'Valuation', format: (v) => v === 0 ? '0' : v ? v.toFixed(2) : '-' },
{ key: 'currentStockGross', label: 'Stock Gross', group: 'Valuation', format: (v) => v === 0 ? '0' : v ? v.toFixed(2) : '-' },
-3
View File
@@ -6,7 +6,6 @@ export interface Product {
price: string; // numeric(15,3)
regular_price: string; // numeric(15,3)
cost_price: string; // numeric(15,3)
landing_cost_price: string | null; // numeric(15,3)
barcode: string;
vendor: string;
vendor_reference: string;
@@ -126,7 +125,6 @@ export interface ProductMetric {
currentPrice: number | null;
currentRegularPrice: number | null;
currentCostPrice: number | null;
currentLandingCostPrice: number | null;
currentStock: number;
currentStockCost: number | null;
currentStockRetail: number | null;
@@ -310,7 +308,6 @@ export type ProductMetricColumnKey =
| 'currentPrice'
| 'currentRegularPrice'
| 'currentCostPrice'
| 'currentLandingCostPrice'
| 'configSafetyStock'
| 'replenishmentUnits'
| 'stockCoverInDays'