v0.11.1 - Fixed weight Discrepancy bug
This commit is contained in:
@@ -102,7 +102,7 @@
|
||||
onclick="openScanDetail('{{ scan.entry_id }}')">
|
||||
<div class="scan-row-lot">{{ scan.lot_number }}</div>
|
||||
<div class="scan-row-item">{{ scan.item or 'N/A' }}</div>
|
||||
<div class="scan-row-weight">{{ scan.actual_weight }} lbs</div>
|
||||
<div class="scan-row-weight">{{ '%.1f'|format(scan.actual_weight) if scan.actual_weight is not none else '-' }} lbs</div>
|
||||
<div class="scan-row-status">
|
||||
{% if scan.duplicate_status == '01' or scan.duplicate_status == '04' %}
|
||||
<span class="status-dot status-dot-blue"></span> Duplicate
|
||||
@@ -185,6 +185,23 @@ let currentLotNumber = '';
|
||||
let isDuplicateConfirmed = false;
|
||||
let isProcessing = false;
|
||||
|
||||
function parseWeight(value) {
|
||||
const num = Number(value);
|
||||
return Number.isFinite(num) ? num : null;
|
||||
}
|
||||
|
||||
function formatWeight(value) {
|
||||
const num = parseWeight(value);
|
||||
return num === null ? '-' : num.toFixed(1);
|
||||
}
|
||||
|
||||
function weightsDiffer(actual, expected) {
|
||||
const actualNum = parseWeight(actual);
|
||||
const expectedNum = parseWeight(expected);
|
||||
if (actualNum === null || expectedNum === null) return false;
|
||||
return Math.abs(actualNum - expectedNum) >= 0.01;
|
||||
}
|
||||
|
||||
// Lot scan handler
|
||||
document.getElementById('lotScanForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
@@ -388,7 +405,7 @@ function addScanToList(data, weight) {
|
||||
statusDot = 'orange';
|
||||
}
|
||||
} else if (data.master_status === 'match') {
|
||||
if (data.master_expected_weight && Math.abs(weight - data.master_expected_weight) >= 0.01) {
|
||||
if (data.master_expected_weight && weightsDiffer(weight, data.master_expected_weight)) {
|
||||
statusClass = 'weight_discrepancy';
|
||||
statusText = 'Weight Off';
|
||||
statusDot = 'orange';
|
||||
@@ -414,7 +431,7 @@ function addScanToList(data, weight) {
|
||||
scanRow.innerHTML = `
|
||||
<div class="scan-row-lot">${currentLotNumber}</div>
|
||||
<div class="scan-row-item">${data.item || 'N/A'}</div>
|
||||
<div class="scan-row-weight">${weight} lbs</div>
|
||||
<div class="scan-row-weight">${formatWeight(weight)} lbs</div>
|
||||
<div class="scan-row-status">
|
||||
<span class="status-dot status-dot-${statusDot}"></span> ${statusText}
|
||||
</div>
|
||||
@@ -451,7 +468,7 @@ function displayScanDetail(scan) {
|
||||
// Check for weight discrepancy (Tolerance 0.01)
|
||||
let isWeightOff = false;
|
||||
if (scan.master_status === 'match' && scan.master_expected_weight) {
|
||||
if (Math.abs(scan.actual_weight - scan.master_expected_weight) >= 0.01) {
|
||||
if (weightsDiffer(scan.actual_weight, scan.master_expected_weight)) {
|
||||
isWeightOff = true;
|
||||
}
|
||||
}
|
||||
@@ -502,7 +519,7 @@ function displayScanDetail(scan) {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Weight (lbs)</label>
|
||||
<input type="number" id="editWeight" class="form-input" value="${scan.actual_weight}" step="0.01" min="0" inputmode="decimal">
|
||||
<input type="number" id="editWeight" class="form-input" value="${formatWeight(scan.actual_weight)}" step="0.01" min="0" inputmode="decimal">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Comment</label>
|
||||
|
||||
Reference in New Issue
Block a user