Fix receipt rounding: round line items to cents before summing

Individual line prices were displayed rounded (via dollars()) but the
raw floating-point values were accumulated into the subtotal. This caused
totals like $0.99 instead of $1.00 when item prices had fractional cents.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mike 2026-03-22 21:33:42 +00:00
parent c05bbe684f
commit fd3183035e

View file

@ -91,10 +91,10 @@ foreach ($parentItems as $parent) {
$qty = (int) $parent['Quantity'];
if ((int) $parent['CategoryID'] !== 31) {
$payfritsCut += $price * $qty * (float) $order['PayfritFee'];
$payfritsCut += round($price * $qty * (float) $order['PayfritFee'], 2);
}
$lineTotal = $price * $qty;
$lineTotal = round($price * $qty, 2);
$cartGrandTotal += $lineTotal;
$itemRows .= '<tr>';
@ -116,7 +116,7 @@ foreach ($parentItems as $parent) {
foreach ($children as $child) {
$modParent = queryOne("SELECT Name FROM Items WHERE ID = ?", [(int) $child['ParentItemID']]);
$modParentName = $modParent['Name'] ?? '';
$modTotal = (float) $child['Price'] * $qty;
$modTotal = round((float) $child['Price'] * $qty, 2);
$cartGrandTotal += $modTotal;
$itemRows .= '<tr class="modifier">';