Rounding error in item cost

Fixed rounding errors on character sheet.
master
The Happy Anarchist 2020-09-05 01:02:19 -10:00
parent dbae5b4d35
commit 0263fa5e2f
2 changed files with 5 additions and 1 deletions

View File

@ -34,6 +34,10 @@ export const registerHelpers = async function () {
return parseFloat(lh) * parseFloat(rh); return parseFloat(lh) * parseFloat(rh);
}); });
Handlebars.registerHelper("multround", function (lh, rh) {
return Math.round((parseFloat(lh) * parseFloat(rh)) * 100) / 100;
})
Handlebars.registerHelper("roundWeight", function (weight) { Handlebars.registerHelper("roundWeight", function (weight) {
return Math.round(parseFloat(weight) / 100) / 10; return Math.round(parseFloat(weight) / 100) / 10;
}); });

View File

@ -176,7 +176,7 @@
</h4> </h4>
</a> </a>
</div> </div>
<div class="field-long">{{mult item.data.quantity.value item.data.cost}}</div> <div class="field-long">{{multround item.data.quantity.value item.data.cost}}</div>
<div class="field-short quantity"> <div class="field-short quantity">
<input value="{{item.data.quantity.value}}" type="text" <input value="{{item.data.quantity.value}}" type="text"
placeholder="0" />{{#if item.data.quantity.max}}<span>/{{item.data.quantity.max}}</span>{{/if}} placeholder="0" />{{#if item.data.quantity.max}}<span>/{{item.data.quantity.max}}</span>{{/if}}