/**
 * 从列表行 / 弹窗入参中解析总仓售价
 * 兼容 snake / camel 及嵌套 central_warehouse_drug
 */
export function resolveCentralPrice(
  source: Record<string, any> | null | undefined,
): number | null {
  if (!source) return null;
  const nested =
    source.central_warehouse_drug ?? source.centralWarehouseDrug ?? null;
  const candidates = [
    source.central_price,
    source.centralPrice,
    nested?.price,
    source.sale_price,
    source.price,
  ];
  for (const c of candidates) {
    const n = Number(c);
    if (n > 0) return Number(n.toFixed(4));
  }
  return null;
}
