Updated total_quantity and scanned_quantity display query logic against material invoice for various types #952

Merged
jothi merged 1 commits from ranjith-dev into master 2026-08-27 10:26:34 +00:00

View File

@@ -216,8 +216,19 @@ class CreateInvoiceValidation extends CreateRecord
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
if ($totMQuan > 0) {
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0; // ->where('quantity', '!=', '')
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totMQuan;
$scanMatQuan = $scanMQuan;
}
$this->form->fill([
'plant_id' => $plantId,
@@ -834,8 +845,19 @@ class CreateInvoiceValidation extends CreateRecord
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', '');
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totalQuantity;
$scanMatQuan = $scannedQuantity;
}
$this->form->fill([
'plant_id' => $plantId,
@@ -870,8 +892,19 @@ class CreateInvoiceValidation extends CreateRecord
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', '');
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totalQuantity;
$scanMatQuan = $scannedQuantity;
}
$this->form->fill([
'plant_id' => $plantId,
@@ -1931,8 +1964,19 @@ class CreateInvoiceValidation extends CreateRecord
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', '');
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totalQuantity;
$scanMatQuan = $scannedQuantity;
}
$this->form->fill([
'plant_id' => $plantId,
@@ -1968,8 +2012,19 @@ class CreateInvoiceValidation extends CreateRecord
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', '');
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totalQuantity;
$scanMatQuan = $scannedQuantity;
}
$this->form->fill([
'plant_id' => $plantId,
@@ -2468,8 +2523,19 @@ class CreateInvoiceValidation extends CreateRecord
return;
} else {
if ($totMQuan > 0) {
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', '');
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totQuan;
$scanMatQuan = $scanMQuan;
}
if ($totQuan == $scanMQuan) {
Notification::make()
@@ -3142,8 +3208,19 @@ class CreateInvoiceValidation extends CreateRecord
$totQuan = InvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', '');
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totQuan;
$scanMatQuan = $scanMQuan;
}
$this->form->fill([
'plant_id' => $plantId,
@@ -3516,8 +3593,19 @@ class CreateInvoiceValidation extends CreateRecord
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', '');
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
Notification::make()
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
->info()
->seconds(1)
->send();
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
} else {
$totMatQuan = $totQuan;
$scanMatQuan = $scannedMQuantity;
}
if ($totQuan == $scannedMQuantity) {
Notification::make()