Preisrechner: Rappenrundung im Backend und Rabatt-Rechner im Web
agentd task ad07191c406d4ea496b0b18db826651e
This commit is contained in:
@@ -16,6 +16,8 @@ public static class PriceCalculator
|
||||
throw new ArgumentOutOfRangeException(nameof(discountPercent), "A discount is between 0 and 100 percent.");
|
||||
}
|
||||
|
||||
return price - discountPercent;
|
||||
var discounted = price * (1 - discountPercent / 100m);
|
||||
// Swiss rounding (Rappenrundung): round to the nearest 0.05
|
||||
return Math.Round(discounted / 0.05m, MidpointRounding.ToEven) * 0.05m;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user