/**
 * Current available stock.
 * Calculation: stock - removedFromStock
 * Returns 0 if result is negative.
 *
 * @remarks
 * Used as the base for further stock calculations.
 */
export const calculateAvailableStock = ({
  stock,
  removedFromStock,
}: {
  stock: number | undefined;
  removedFromStock?: number;
}): number => {
  const availableStock = (stock ?? 0) - (removedFromStock ?? 0);
  return availableStock < 0 ? 0 : availableStock;
};
