fix: avoid division by zero in AgileCalculator

master
Katja Lutz 2 years ago
parent e43be215b5
commit 309a9754b0

@ -15,7 +15,7 @@ const AgileCalculator: Component = () => {
}); });
const calculatorQuantity = createMemo(() => const calculatorQuantity = createMemo(() =>
calculateAgileQuantity( calculateAgileQuantity(
agileCalculator.hoursPerPoint, 1,
new Big(agileCalculator.risk).div(100).toNumber(), new Big(agileCalculator.risk).div(100).toNumber(),
agileCalculator.minPoints, agileCalculator.minPoints,
agileCalculator.maxPoints agileCalculator.maxPoints
@ -110,18 +110,12 @@ const AgileCalculator: Component = () => {
<div class="p-1"> <div class="p-1">
<div class="flex justify-between"> <div class="flex justify-between">
<span>Gewichtete Story Points:</span> <span>Gewichtete Story Points:</span>
{new Big(calculatorQuantity()) {calculatorQuantity()} SP
.div(agileCalculator.hoursPerPoint)
.toNumber()}{" "}
SP
</div> </div>
</div> </div>
<div class="p-1 font-mono text-sm text-right"> <div class="p-1 font-mono text-sm text-right">
<span title="Gewichtete Story Points" class="text-title-border"> <span title="Gewichtete Story Points" class="text-title-border">
{new Big(calculatorQuantity()) {calculatorQuantity()} SP
.div(agileCalculator.hoursPerPoint)
.toNumber()}{" "}
SP
</span>{" "} </span>{" "}
*{" "} *{" "}
<span title="Stunden pro Story Point" class="text-title-border"> <span title="Stunden pro Story Point" class="text-title-border">
@ -137,7 +131,10 @@ const AgileCalculator: Component = () => {
<div class="flex justify-between"> <div class="flex justify-between">
<span>Gesamtpreis:</span> <span>Gesamtpreis:</span>
{formatAmount( {formatAmount(
calculatorQuantity() * agileCalculator.singlePrice new Big(calculatorQuantity())
.mul(agileCalculator.hoursPerPoint)
.mul(agileCalculator.singlePrice)
.toNumber()
)}{" "} )}{" "}
CHF CHF
</div> </div>

Loading…
Cancel
Save