namespace Fitness_core_BE.Domain { public static class DiscountCalculator { public static decimal ComputeDiscountAmount(decimal subtotal, string? discountType, decimal? discountValue) { if (string.IsNullOrEmpty(discountType) || discountValue is not decimal value || value <= 0 || subtotal <= 0) return 0m; var discount = discountType switch { "Percentage" => subtotal * Math.Clamp(value, 0m, 100m) / 100m, "Flat" => Math.Clamp(value, 0m, subtotal), _ => 0m }; return Math.Round(discount, 2); } } }