Changed logic in cycle count #830

Merged
jothi merged 1 commits from ranjith-dev into master 2026-07-16 09:56:52 +00:00
Showing only changes of commit 947aacb074 - Show all commits

View File

@@ -128,7 +128,8 @@ class CycleCount extends Page
$operatorName = $user->name;
$pattern1 = '/^[^#]*#[^#]*#[^#]*#[^#]*#$/';
$pattern2 = '/^[^|]*\|[^|]*\|[^|]*$/';
// $pattern2 = '/^[^|]*\|[^|]*\|[^|]*$/';
$pattern2 = '/^[^|]+\|[^|]+(?:\|[^|]*)?$/';
$pattern3 = '/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPp])?\|?$/';
// $pattern2 = '/^[^|]+\|[^|]+\|[^|]+\|?$/'; Optional Pipeline at end
@@ -721,13 +722,28 @@ class CycleCount extends Page
$parts = explode('|', $value);
$this->itemCode = $parts[0] ?? null;
if (strlen($parts[1]) > strlen($parts[2])) {
if (count($parts) == 2) {
// Format: itemcode|serialnumber
$this->sNo = $parts[1];
$this->batch = $parts[2];
$this->batch = null;
} else {
$this->batch = $parts[1];
$this->sNo = $parts[2];
// Format: itemcode|value1|value2
if (strlen($parts[1]) > strlen($parts[2])) {
$this->sNo = $parts[1];
$this->batch = $parts[2];
} else {
$this->batch = $parts[1];
$this->sNo = $parts[2];
}
}
// if (strlen($parts[1]) > strlen($parts[2])) {
// $this->sNo = $parts[1];
// $this->batch = $parts[2];
// } else {
// $this->batch = $parts[1];
// $this->sNo = $parts[2];
// }
if (strlen($this->itemCode) < 6) {
Notification::make()
@@ -759,7 +775,7 @@ class CycleCount extends Page
]);
return;
} elseif (strlen($this->batch) < 5) {
} elseif (count($parts) !== 2 && strlen($this->batch) < 5) {
Notification::make()
->title('Unknown Batch')
->body("Batch should contain minimum 5 digits '$this->batch'")
@@ -927,7 +943,7 @@ class CycleCount extends Page
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch,
'batch' => $this->batch ?? null,
'docNo' => $this->docNo,
'quantity' => $this->quantity,
]),
@@ -1240,7 +1256,7 @@ class CycleCount extends Page
return;
}
if ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null) {
if (count($parts) !== 2 && ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null)){
if ($serialAgaPlant->batch != $this->batch) {
@@ -1396,7 +1412,7 @@ class CycleCount extends Page
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch,
'batch' => $this->batch ?? null,
'docNo' => $this->docNo,
'quantity' => $this->quantity,
]),
@@ -1416,7 +1432,7 @@ class CycleCount extends Page
$serial->update([
'bin' => $bin ?? null,
'batch' => $this->batch ?? null,
'doc_no' => $this->docNo ?? null,
// 'doc_no' => $this->docNo ?? null,
'scanned_status' => 'Scanned',
'scanned_quantity' => '1',
'updated_at' => now(),
@@ -2132,6 +2148,7 @@ class CycleCount extends Page
}
}
}
}
protected function getHeaderActions(): array