Updated invoice_quantity value to trace scanned and pending quantity for the item code in create page
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s

This commit is contained in:
dhanabalan
2026-06-18 21:17:06 +05:30
parent 8efd64545d
commit f82c3fe390

View File

@@ -611,6 +611,7 @@ class CreateInvoiceValidation extends CreateRecord
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'invoice_quantity' => 1,
'quantity' => 1,
'operator_id' => $operatorName,
'created_by' => $operatorName,
@@ -653,6 +654,7 @@ class CreateInvoiceValidation extends CreateRecord
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'invoice_quantity' => $bundleQty,
'quantity' => $bundleQty,
'operator_id' => $operatorName,
'created_by' => $operatorName,
@@ -697,11 +699,13 @@ class CreateInvoiceValidation extends CreateRecord
// 8 = 3 + 5 // 8 = 5 + 3 // 8 = 0 + 8 // 8 = 8 + 0
// 8 = 3 + 5 // 8 = 5 + 3 // 8 = 0 + 8 // 8 = 8 + 0
// 0 = 0 + 0
// 4 = 1.5 + 2.5
$existQty = $existEmpQty + $existComQty;
// 8 <= 11 // 8 <= 8 // 8 <= 11 // 8 <= 9
// 8 <= 7 // 8 <= 7 // 8 <= 7 // 8 <= 7
// 0 <= 5
// 4 <= 2
if ($existQty <= $totalExcelQty) {
// 6 = 11 - 5 // 5 = 8 - 3 // 3 = 11 - 8 // 9 = 9 - 0
@@ -723,29 +727,46 @@ class CreateInvoiceValidation extends CreateRecord
'updated_by' => $operatorName,
'updated_at' => now(),
]);
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
->update([
'invoice_quantity' => $totalExcelQty,
]);
$newQuan--;
$inserted++;
} elseif ($newInsQty > 0) { // if ($sticker) // create
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
->update([
'invoice_quantity' => $totalExcelQty,
]);
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'invoice_quantity' => $totalExcelQty,
'quantity' => $newInsQty,
'operator_id' => $operatorName,
'created_by' => $operatorName,
'updated_by' => $operatorName,
]);
$inserted++;
}
}
// 8 > 7 // 8 > 7 // 8 > 7 // 8 > 7
// 4 > 2
else {
// 2 = 7 - 5 // 4 = 7 - 3 // -1 = 7 - 8 // 7 = 7 - 0
// -0.5 = 2 - 2.5 //
$newInsQty = $totalExcelQty - $existComQty;
// 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0
if ($existEmpQty > 0) { // update
// 1.5 > 0 //
if ($newInsQty > 0 && $existEmpQty > 0) { // update
// 3 = 2 // 5 = 4 // 0 = -1 // 8 = 7
// 1.5 == -0.5 //
if ($existEmpQty == $newInsQty) {
continue;
}
@@ -756,6 +777,12 @@ class CreateInvoiceValidation extends CreateRecord
'updated_by' => $operatorName,
'updated_at' => now(),
]);
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
->update([
'invoice_quantity' => $totalExcelQty,
]);
$newQuan--;
$inserted++;
} elseif ($newInsQty > 0) { // create
@@ -763,11 +790,18 @@ class CreateInvoiceValidation extends CreateRecord
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'invoice_quantity' => $totalExcelQty,
'quantity' => $newInsQty,
'operator_id' => $operatorName,
'created_by' => $operatorName,
'updated_by' => $operatorName,
]);
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
->update([
'invoice_quantity' => $totalExcelQty,
]);
$inserted++;
}
}
@@ -1791,6 +1825,7 @@ class CreateInvoiceValidation extends CreateRecord
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'invoice_quantity' => 1,
'quantity' => 1,
'operator_id' => $operatorName,
'created_by' => $operatorName,
@@ -1826,6 +1861,7 @@ class CreateInvoiceValidation extends CreateRecord
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'invoice_quantity' => $bundleQty,
'quantity' => $bundleQty,
'operator_id' => $operatorName,
'created_by' => $operatorName,
@@ -1859,6 +1895,7 @@ class CreateInvoiceValidation extends CreateRecord
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'invoice_quantity' => $totalExcelQty,
'quantity' => $totalExcelQty,
'operator_id' => $operatorName,
'created_by' => $operatorName,
@@ -3347,6 +3384,7 @@ class CreateInvoiceValidation extends CreateRecord
$createdDt = $record->created_at;
$stickMasterId = $record->sticker_master_id;
$curExistQty = $record->quantity;
$curItemInvQty = $record->invoice_quantity;
// $curScanQty = 2;
if ($curExistQty > $curScanQty) { // 5 > 2
@@ -3362,6 +3400,7 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => $serialNumber,
'batch_number' => $batchNumber,
'invoice_quantity' => $curItemInvQty,
'quantity' => $curScanQty,
'created_at' => $createdDt,
'operator_id' => $operatorName,
@@ -3545,6 +3584,7 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
}
// TN01/BOX22/SERIAL999 >> PANEL BOX QR
// /^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/
if (! preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $serNo, $matches)) {
Notification::make()