fix : auto clear is added (working)

This commit is contained in:
karthik 2025-08-13 11:50:04 +05:30
parent 3baed644a1
commit 9451abf500

View File

@ -627,11 +627,17 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
if (this.selectedLabel === 'WSP') {
this.wspTicketStage = 0; // Reset stage if WSP
}
else if (/[0-9]/.test(key)) {
const currentValue = parseInt(this.padValue + key) || 0;
if (currentValue > 100) return;
this.padValue += key;
}
// Clear the current row to reset any invalid state
this.selectionService.updatePartial({
label: this.selectedLabel || '',
numbers: [...this.selectedNumbers],
value: 0,
total: 0,
isBoxed: this.isBoxed
});
this.updateCanPrint();
return;
}
if (/[0-9]/.test(key)) {
@ -661,16 +667,53 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
});
this.selectionService.setSelections(updatedSelections);
// Check if total is 0 for WSP (indicating invalid row)
const currentTotal = updatedSelections.find(sel => sel.label === targetLabel)?.total || 0;
if (currentTotal === 0 && value > 0) {
console.log('[DEBUG] WSP row invalid (total = 0), clearing row');
this.selectionService.setSelections(
updatedSelections.filter(sel => sel.label !== targetLabel || sel.numbers.length > 0)
);
this.wspTicketStage = 0;
this.padValue = '';
this.selectedNumbers = [];
this.selectionService.updatePartial({
label: '',
numbers: [],
value: 0,
total: 0,
isBoxed: false
});
}
return;
}
// 🔵 Default path for non-WSP
// Default path for non-WSP
this.selectionService.updatePartial({
value,
isBoxed: this.isBoxed,
label: this.selectedLabel || '',
numbers: [...this.selectedNumbers]
});
// Check if total is 0 after updating (indicating invalid mathematical logic)
const currentRow = this.selectionService.getCurrentRow();
if (currentRow.total === 0 && value > 0 && currentRow.numbers.length > 0) {
console.log('[DEBUG] Row invalid (total = 0), auto-clearing current row');
this.selectionService.updatePartial({
label: '',
numbers: [],
value: 0,
total: 0,
isBoxed: false
});
this.selectedLabel = null;
this.selectedNumbers = [];
this.padValue = '';
this.isBoxed = false;
this.updateCanPrint();
}
}
//---------------------------------------------------------------------------------------------