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:
parent
c05bbe684f
commit
fd3183035e
1 changed files with 3 additions and 3 deletions
|
|
@ -91,10 +91,10 @@ foreach ($parentItems as $parent) {
|
||||||
$qty = (int) $parent['Quantity'];
|
$qty = (int) $parent['Quantity'];
|
||||||
|
|
||||||
if ((int) $parent['CategoryID'] !== 31) {
|
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;
|
$cartGrandTotal += $lineTotal;
|
||||||
|
|
||||||
$itemRows .= '<tr>';
|
$itemRows .= '<tr>';
|
||||||
|
|
@ -116,7 +116,7 @@ foreach ($parentItems as $parent) {
|
||||||
foreach ($children as $child) {
|
foreach ($children as $child) {
|
||||||
$modParent = queryOne("SELECT Name FROM Items WHERE ID = ?", [(int) $child['ParentItemID']]);
|
$modParent = queryOne("SELECT Name FROM Items WHERE ID = ?", [(int) $child['ParentItemID']]);
|
||||||
$modParentName = $modParent['Name'] ?? '';
|
$modParentName = $modParent['Name'] ?? '';
|
||||||
$modTotal = (float) $child['Price'] * $qty;
|
$modTotal = round((float) $child['Price'] * $qty, 2);
|
||||||
$cartGrandTotal += $modTotal;
|
$cartGrandTotal += $modTotal;
|
||||||
|
|
||||||
$itemRows .= '<tr class="modifier">';
|
$itemRows .= '<tr class="modifier">';
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue