ChemPal Documentation - v1.6.0
    Preparing search index...

    Function getProductPriceHistory

    • Read all recorded price-history series for a product — its base row plus any variant rows — keyed by series id for direct lookup from the detail UI.

      Parameters

      • product: Product

        The product whose history to load.

      Returns Promise<Map<string, PriceHistoryEntry>>

      A map of series id → PriceHistoryEntry; empty when the product can't be keyed or has no recorded history.

      const byId = await getProductPriceHistory(product);
      const base = byId.get(productSeriesKey(product) ?? "");
      export async function getProductPriceHistory(
      product: Product,
      ): Promise<Map<string, PriceHistoryEntry>> {
      const productKey = productSeriesKey(product);
      if (productKey === undefined) {
      return new Map();
      }
      const series = await getPriceSeriesByProduct(productKey);
      return new Map(series.map((entry) => [entry.id, entry]));
      }