import { ReceiptItem } from '../../models';
import { ProductCategory } from '../../questions';

/**
 * Checks if a receipt item has the specified product category.
 *
 * @param item - The receipt item to check.
 * @param category - The product category to compare against.
 * @returns True if the item's features contain the specified category, otherwise false.
 *
 * @remarks
 * - Returns false if the 'features' property is missing.
 * - Performs a strict equality check between the item's category and the provided category.
 */
export function receiptItemHasCategory(
  item: ReceiptItem,
  category: ProductCategory,
) {
  if (!item.features) {
    return false;
  }
  const itemCategory = item.features['category'];
  return itemCategory === category;
}
