import { config } from './config';

/** Apply configured catalog discount (e.g. 40 → price × 0.6). Returns price unchanged when disabled. */
export function applyPriceDiscount(price: number): number {
  if (!Number.isFinite(price) || price <= 0) return price;
  const pct = config.pricing.discountPercent;
  if (pct <= 0 || pct >= 100) return Math.round(price * 100) / 100;
  return Math.round(price * ((100 - pct) / 100) * 100) / 100;
}
