Preisrechner: Rappenrundung im Backend und Rabatt-Rechner im Web

agentd task ad07191c406d4ea496b0b18db826651e
This commit is contained in:
agentd
2026-08-05 00:32:00 +00:00
parent 605a952f7a
commit 724ee92a2b
6 changed files with 236 additions and 2 deletions

View File

@@ -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;
}
}