20260316f: Fix Cracker integrali default_qty (500→16) + detect absurd package sizes
- Fixed Cracker integrali default_quantity from 500 to 16 (was weight in grams, should be pieces)
- Review system now also flags products with absurd default_quantity (package size)
e.g. a 'pz' product claiming 500pz per package gets flagged as '📦 Conf. sospetta'
- Uses same QTY_THRESHOLDS max values for detection
This commit is contained in:
+14
-3
@@ -958,6 +958,13 @@ function isSuspiciousQty(qty, unit) {
|
||||
return n < t.min || n > t.max;
|
||||
}
|
||||
|
||||
function isSuspiciousDefaultQty(defaultQty, unit) {
|
||||
const n = parseFloat(defaultQty);
|
||||
if (!n || n <= 0) return false;
|
||||
const t = QTY_THRESHOLDS[unit] || QTY_THRESHOLDS['pz'];
|
||||
return n > t.max;
|
||||
}
|
||||
|
||||
function getReviewConfirmed() {
|
||||
return _reviewConfirmedCache || {};
|
||||
}
|
||||
@@ -981,7 +988,7 @@ async function loadReviewItems() {
|
||||
|
||||
const suspicious = items.filter(item => {
|
||||
if (confirmed[item.id]) return false;
|
||||
return isSuspiciousQty(item.quantity, item.unit);
|
||||
return isSuspiciousQty(item.quantity, item.unit) || isSuspiciousDefaultQty(item.default_quantity, item.unit);
|
||||
});
|
||||
|
||||
if (suspicious.length === 0) {
|
||||
@@ -995,8 +1002,12 @@ async function loadReviewItems() {
|
||||
const qtyDisplay = formatQuantity(item.quantity, item.unit, item.default_quantity, item.package_unit);
|
||||
const locInfo = LOCATIONS[item.location] || { icon: '📦', label: item.location };
|
||||
const t = QTY_THRESHOLDS[item.unit] || QTY_THRESHOLDS['pz'];
|
||||
const isTooSmall = parseFloat(item.quantity) < t.min;
|
||||
const warning = isTooSmall ? '⬇️ Troppo poco' : '⬆️ Troppo';
|
||||
const suspQty = isSuspiciousQty(item.quantity, item.unit);
|
||||
const suspDq = isSuspiciousDefaultQty(item.default_quantity, item.unit);
|
||||
let warning;
|
||||
if (suspDq && !suspQty) warning = '📦 Conf. sospetta';
|
||||
else if (parseFloat(item.quantity) < t.min) warning = '⬇️ Troppo poco';
|
||||
else warning = '⬆️ Troppo';
|
||||
|
||||
return `
|
||||
<div class="review-item" id="review-item-${item.id}">
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -911,6 +911,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/app.js?v=20260316e"></script>
|
||||
<script src="assets/js/app.js?v=20260316f"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user