fix roundings

This commit is contained in:
O K
2025-09-13 12:17:01 +03:00
parent 72bfbef4a8
commit b05f094eef

View File

@@ -73,9 +73,7 @@ class CheckPrestaBox extends Module
$this->processNewFiscalForm((int) $params['id_order']); $this->processNewFiscalForm((int) $params['id_order']);
$orderURL = $router->generate('admin_orders_view', [ $orderURL = $router->generate('admin_orders_view', [
'orderId' => (int) $params['id_order'], 'orderId' => (int) $params['id_order'],
]) . '#checkprestaboxTabContent';
]).'#checkprestaboxTabContent';
Tools::redirectAdmin($orderURL); Tools::redirectAdmin($orderURL);
} }
@@ -122,7 +120,7 @@ class CheckPrestaBox extends Module
foreach ($submittedProducts as $product) { foreach ($submittedProducts as $product) {
$price = round((float)($product['price'] ?? 0.0) * 100, 2); $price = round((float)($product['price'] ?? 0.0), 2) * 100;
$quantity = (int)($product['quantity'] ?? 0) * 1000; $quantity = (int)($product['quantity'] ?? 0) * 1000;
if ($quantity == 0) { if ($quantity == 0) {
continue; continue;
@@ -133,7 +131,7 @@ class CheckPrestaBox extends Module
'good' => [ 'good' => [
'code' => (string)($product['code'] ?? ''), 'code' => (string)($product['code'] ?? ''),
'name' => (string)($product['name'] ?? 'Unknown Product'), 'name' => (string)($product['name'] ?? 'Unknown Product'),
'price' => $price, 'price' => round((float) $price, 2),
], ],
'quantity' => $quantity, 'quantity' => $quantity,
]; ];
@@ -148,7 +146,7 @@ class CheckPrestaBox extends Module
$paymentsForFiscalize[] = [ $paymentsForFiscalize[] = [
'type' => $payment['type'] == 'Готівка' ? 'CASH' : 'CASHLESS', 'type' => $payment['type'] == 'Готівка' ? 'CASH' : 'CASHLESS',
'label' => $payment['type'], 'label' => $payment['type'],
'value' => round($value, 2), 'value' => round((float) $value, 2),
]; ];
} }
@@ -162,7 +160,7 @@ class CheckPrestaBox extends Module
$discountsForFiscalize[] = [ $discountsForFiscalize[] = [
'type' => 'DISCOUNT', 'type' => 'DISCOUNT',
'mode' => 'VALUE', 'mode' => 'VALUE',
'value' => $value, 'value' => round((float) $value, 2),
'name' => $cart_rule['name'], 'name' => $cart_rule['name'],
]; ];
} }
@@ -437,7 +435,6 @@ class CheckPrestaBox extends Module
$headers = [ $headers = [
'X-License-Key: ' . $key, 'X-License-Key: ' . $key,
]; ];
$resp = $this->apiCall('/api/v1/shifts', [], 'POST', null); $resp = $this->apiCall('/api/v1/shifts', [], 'POST', null);
if (isset($resp['id']) && isset($resp['status']) && $resp['status'] == 'CREATED') { if (isset($resp['id']) && isset($resp['status']) && $resp['status'] == 'CREATED') {
return $resp['id']; return $resp['id'];